• Post Categories

  • Browse Blogs

  • Blog Stats

    • 624,384 hits
  • Syndications

    SQLServerPedia Contributor

Todo lo que debes saber sobre SSIS en 1 hora!

Gracias a lo asistentes de mi charla Todo lo que debes saber sobre SSIS en 1 hora! en el evento 24HOP LATAM. La verdad me agrado mucho presentar en espanol. Aun cuando mi primera lengua es espanol, todas las presentaciones tecnicas en el pasado las he realizado en ingles.

Si deseas ver la presentacion PowerPoint puedes bajarla dando click en la imagen a continuacion.

Tambien puedes bajar el proyecto que utilize en mi presentacion dando click en la imagen a continuacion. Nota: Solo podras utilizar la base de datos y proyecto en SQL Server Denali, no servira en SQL Server 2008 o 2005.


MDS Error: MDMMemberStatus does not de-activate members through the StgMemberAttribute table

Master Data Services provides a way of de-activating entity members using the StgMemberAttribute table as described in Books On Line http://msdn.microsoft.com/en-us/library/ee633772.aspx

This is a somewhat straightforward approach and requires for you to populate the StgMemberAttribute table with AttributeCode (actual code of the member in MDS), AttributeName as “MDMMemberStatus” and AttributeValue as “De-Activated”.

In a recent MDS implementation, I came across an error when I was trying to de-activate all members from an entity. I followed the same steps I usually follow but the members were still not being deactivated. I noticed that after the rows were processed, a batch number was assigned but the Status_ID column in the StgMemberAttribute remained unchanged with the default value of 0 (ready for staging). The ErrorCode column also remained unchanged.

After several hours of research I bumped into a fix introduced in the MDS June 2010 Cumulative Update. The fix found under the Import and Export section states:

The staging process supports the deletion of members from an entity that supplies domain-based attribute values for another entity.

Bingo! The members I was trying to de-activate were part of an entity being used as the source of a domain-based attribute of another entity. I had confirmed that no members were being referenced and I even deleted this referencing domain-based attribute while trying to de-activate the members.

After applying the MDS June 2010 Cumulative Update I was able to delete the members of this entity. 

As of the date of this post, Service Pack 1 and two additional Cumulative Updates have been released for MDS. You can check what was fixed in these updates and how to install them at the MDS team blog site: http://sqlblog.com/blogs/mds_team/archive/2010/02/10/staging-examples.aspx

Download all SQL Server DENALI CTP3 Demo VHD 36 files at once

Microsoft has made available for download the SQL Server DENALI CTP3 Demo VHD several weeks ago at http://www.microsoft.com/download/en/details.aspx?id=27740. The SQL Server DENALI CTP3 Demo VHD is a fully configured HyperV image of SQL Server Denali CTP3  and SharePoint 2010 good for 180 days. The following software is configured on the virtual machine:

  • SQL Server “Denali” CTP3
  • SharePoint 2010
  • Office 2010

You may want to download this pre-built image to test and play with all the new features available in SQL Server Denali CTP3 and SharePoint 2010 without going through the hassle of building the environment yourself.

The vhd file has been broken down into 36 compressed (RAR) files of 700MB each. You can avoid the pain of downloading each file one by one using a download manager such as the Download Accelerator Plus (DAP).

DAP is my favorite download manager for 3 simple reasons:

  1. It’s free
  2. It’s fast
  3. The “Download all with DAP” option

For those of you not familiar with DAP, you can download it for free at http://www.speedbit.com. After downloading and installing DAP, you will notice that one of the options now available when you right-click on a webpage is the “Download all with DAP” as seen in Figure 1.

Figure 1. Download all with DAP option

By default, it will display a list of all downloadable items from the webpage. To filter the file types to download, click on the More button. An additional section displays at the bottom with a button to Filter. Click on the Filter button, and check Custom. Type RAR EXE with a single space in between the two words as shown in Figure 2.

Figure 2. Filter option

Click OK. Only the downloadable items with extension RAR and EXE are selected and ready for download. To start downloading click on the Download Now button. By default only 4 items will download in parallel, the rest will be queued and start downloading when one of the first 4 items complete as shown in Figure 3.

Figure 3. DAP queue

Afterthoughts: SQL Saturday #79 South Florida 2011

This past Saturday August 13th I presented two sessions at SQL Saturday #79 hosted by the South Florida SQL Server User Group (SFSSUG) (Webpage | LinkedIn| Twitter). The first presentation was at 11:00am titled “So, What is BI Semantic Model and why should you care?” and the second one was at 3:00pm titled “Designing  and Optimizing Analysis Services Hierarchies.” I had an amazing time chatting with some old friends that made it to South Florida all the way from Charlotte, NC, Atlanta, GA and  several other Florida cities like Jacksonville, Pensacola, Orlando, and Tampa.

The Driving Adventure

It was an adventure to get there as I decided to make the 4-hour drive from Tampa, FL (about 500 miles round-trip) early in the morning. My original plan was to start my drive around 4:30am but due to being jet lagged from my midnight flight the day before, I woke up until I snoozed the alarm for the 3rd time around 6:30am. That gave me a 30 minute window to get there on time for my 11am session.

The Event

The event was well put together by it’s organizers and volunteers. The food was great and included a mix of Mexican goodies. The Nova Southeastern University Carl DeSantis Building was a great venue. I really liked the central atrium where everybody converged in between sessions and was more than ideal for having lunch and event wrap-up. Great choice of venue & food!

The Attendees

One Mountain Dew + a 5-hour energy bottle and a speeding ticket later, I managed to get there with 20 minutes to spare. My first session titled What is BI Semantic Model and why should you care? started on time and was packed. It was literally standing room only. I had a great time with the audience. They were very engaged and asked both technical and philosophical questions. A couple speakers and friends attended such as my “tweep” (tweeter peep) Phillip Rosen (LinkedIn | Twitter) whom I got to know him in person for the first time. Also, the amazing Data Mining expert and newly minted Microsoft MVP Mark Tabladillo, Ph.D. (Blog | LinkedIn | Twitter) with whom I exchanged a couple of good jokes and funny moments during the presentation. The most memorable being the conception of the term “Bingle” which is the abbreviation of Bing and Google.

Sanjay Soni, Microsoft TSP

One of the attendees was Sanjay Soni (LinkedIn), Microsoft’s new Data and BI Platform Technology Solution Professional (TSP) for the Greater Southeast District (Florida). Sanjay introduced himself after the presentation and was very kind to provide very positive feedback for my BISM presentation. We  spent some time chatting about opportunities to co-present and network some more. I’m very excited to assist Sanjay  as much as I can in his new role in Florida. I encourage for you to network with Sanjay as he is a very friendly and approachable guy. You will see him very soon at a user group or event near you!

At the end of my session several other attendees came up to introduce themselves personally. There were so many I almost ran out of business cards. I appreciate when attendees take a moment to chat with me after my sessions and get the opportunity to listen to their feedback and kind words. I feel truly honored to have been able to present to such a great crowd.

So, What is BI Semantic Model and why should you care?

In this presentation, I did an overview of the new Business Intelligence Semantic Model (BISM) and the new “flavor” of the Analysis Services Engine that Microsoft will release with SQL Server Codename Denali. I explained about the new focus on “Personal BI” with the PowerPivot add-in for Excel, “Workgroup BI” with PowerPivot for SharePoint and “Enterprise BI” with Analysis Services UDM and Tabular mode. I showcased the free PowerPivot add-in for Excel 2010 and later demonstrated how easily a PowerPivot workbook can now be turned into an enterprise grade Tabular database using the new Business Intelligence Development Studio in SQL Server Codename Denali and how simple it is to deploy them.

You can download the slides here or by clicking on the picture above.

Designing  and Optimizing Analysis Services Hierarchies


On my second presentation Designing and Optimizing Analysis Services Hierarchies I also had a great time interacting with the attendees. The session was designed as an intermediate session but changed it a little bit to more beginner level from the results of my skillset level audience survey. I had great questions and participation from the attendees.

You can download the slides here or by clicking the picture above.

Thanks to everyone who attended my sessions and to the organizers and volunteers that made SQL Saturday #79 a success!

SQL Server Codename “Denali” CTP3 Resources

SQL Server codename “Denali” CTP3 has been released to the public after much anticipation. You may ask yourself, “What happened to CTP2?” The answer is simple. It was a private build for MVPs and some Microsoft partners. By private, I mean it was not released to the general public. The good news is that you did not miss much in CTP2. A lot of areas were incomplete or not working. But that is to be expected as it is a work in progress.

This blog post will serve as a means to gather resources such as links and blog posts regarding SQL Server “Denali” CTP3. Check back soon as I will be adding new resources. If you have a blog post about SQL Server Denali CTP3 please pingback or email me to add it to the list.



A HyperV image of SQL Server Denali CTP3 in action, including fully configured services and integration with SharePoint 2010 and Office 2010
The following software is configured on the virtual machine:

  • SQL Server “Denali” CTP3
  • SharePoint 2010
  • Office 2010

SQL Server codename “Denali” Community Technology Preview 3 CTP3

SQL Server code name “Denali” Express Core Community Technology Preview 3 (CTP 3)

SQL Server code name ‘Denali’ Community Technology Preview 3 (CTP 3) Feature Pack

The SQL Server  code name “Denali” CTP 3 Feature Pack is a collection of stand-alone packages which provide additional value for Microsoft® SQL Server® code name ‘Denali’ CTP 3. It includes the latest versions of  tool and components an add-on providers.


  • SQL Servercode name “Denali” Master Data Service Add-in for Excel CTP 3
  • SQL Servercode name “Denali” Semantic Language Statistics CTP 3
  • SQL ServerReport Builder for SQL Servercode name “Denali” CTP 3
  • SQL Servercode name “Denali” PowerPivot for  Excel CTP 3
  • SQL Servercode name “Denali” Reporting Services Add-in for  SharePoin Technologies
  • SQL Servercode name “Denali” Data-Tier Application Framework CTP 3
  • SQL Servercode name “Denali” Transact-SQL Language Service CTP 3
  • SQL Servercode name “Denali” Transact-SQL ScriptDom CTP 3
  • SQL Servercode name “Denali” Transact-SQL Compiler Service CTP 3
  • SQL ServerCompact 4.0
  • SQL ServerCompact 4.0 Books On-line
  • SQL ServerJDBC Driver 4.0 Community Technology 2 (CTP 2)
  • Connector 1.1 for SAP BW for SQL Server code name “Denali” CTP 3
  • System CLR Types for SQL Server code name “Denali” CTP 3
  • SQL Servercode name “Denali” Remote Blob Store CTP 3
  • SQL Servercode name “Denali” Books On-line CTP 3
  • SQL Servercode name “Denali” Upgrade Advisor CTP 3
  • SQL Servercode name “Denali” Native Client CTP 3
  • OLEDB Provider for DB2 v4.0 for SQL Server code name “Denali” CTP 3
  • SQL Servercode name “Denali” Command Line Utilities CTP 3
  • SQL ServerService Broker External Activator for SQL Server code name “Denali” CTP 3
  • Windows PowerShell Extensions for SQL Server code name “Denali” CTP 3
  • SQL Servercode name “Denali” Shared Management Objects CTP 3
  • SQL Servercode name “Denali” ADOMD.NET CTP 3
  • Analysis Services OLE DB Provider for SQL Servercode name “Denali” CTP 3
  • SQL Servercode name “Denali” Analysis Management Objects CTP 3
  • SQL ServerDriver for PHP 2.0
  • SQL ServerMigration Assistant
    1. Microsoft SQL Server Migration Assistant for Access
    2. Microsoft SQL Server Migration Assistant for MySQL
    3. Microsoft SQL Server Migration Assistant for Oracle
    4. Microsoft SQL Server Migration Assistant for Sybase
    5.  Microsoft SQL Server Migration Assistant 2008 for Sybase PowerBuilder Applications
  • SQL ServerStreamInsight v1.2

Adventure Works sample databases for SQL Server codename Denali CTP3

Denali CTP3 Adventure Works Sample Databases Readme


  • AdventureWorks2008R2 Data File
  • AdventureWorksDWDenali Data File
  • SSAS Multidimensional Model Projects Denali CTP3
  • SSAS Tabular Model Projects Denali CTP3
  • SSAS AMO2Tabular Denali CTP3

Don’t forget to read the sample databases readme file:


Tutorials for SQL Server “Denali”


  • Multidimensional Modeling (Adventure Works Tutorial)
  • Tabular Modeling (Adventure Works Tutorial)
  • Tutorial for Project Crescent

Blogs / Wikis:

Microsoft SQL Server Code-Named “Denali” CTP3 Release Notes

SQL Server Team: SQL Server Code Name “Denali” CTP3 and SQL Server 2008 R2 SP1 are HERE!

SSIS Team Blog: Matt Mason – What’s new in SQL Server Denali?

SQL Server Reporting Services Team Blog: Thierry Dhers – SQL Server codename “Denali” CTP3, including Project “Crescent” is now publically available

What’s New in Master Data Services (MDS) in Denali CTP3

Marco Russo: Installing Analysis Services ssas #Denali CTP3 and PowerPivot Denali CTP3

Brent Ozar: CTP3 is Here! Five Things to Know About the Next Version of SQL Server

Jamie Thompson: SSIS enhancements in Denali CTP3

MSDN SQL Server (Pre-release) forum threads

SQL Server “Deanali” Books Online (BOL)

Technet Wiki: Project Crescent Overview

Update Log:
7/26/2011 Added Denali CTP3 Adventure Works Sample Databases Readme link

9/25/2011 Added SQL Server DENALI CTP3 Demo VHD download link and description and Technet Wiki Project Crescent overview.

T-SQL: Identifying, inserting and removing spaces in strings

Frequently, when working with strings you will need to identify, insert or remove spaces before, after or in between characters.

For example, you may want to show customer full names  by concatenating the columns that hold the different parts of customer names like FirstName, MiddleName, and LastName, separating each name part with a blank space. You may also want to remove spaces before, after or in between characters from email or website addresses. It is important to understand the different string functions available for you in T-SQL that may help you accomplish any of the tasks mentioned above:

Using single-quotes with space in between  ‘ ‘ versus char(32) to insert spaces between characters

Example #1:

DECLARE @FirstName varchar(25), @LastName varchar(25)
SET @FirstName = ‘Jose’
SET @LastName = ‘Chinchilla’
SELECT @FirstName + ‘ ‘ + @LastName — (one space between single-quotes)
–Result=> Jose Chinchilla

Example #2:

SELECT @FirstName + char(32) + @LastName — (single space special character represented by char(32))
–Result=> Jose Chinchilla

From these two examples we can observe that we get the same results by using single quotes with an empty space in between and char(32). The reason is because char(32) is the ASCII code value of a space character in T-SQL.

Result=> 32
Result=> _  — (the underscore character ‘_’ represents a blank space for clarification purposes, no actual underscores will show)
Result=> _ — (the underscore character ‘_’ represents a blank space for clarification purposes, no actual underscores will show)

Using LEN vs DATALENGTH to get the number of characters in a string

Example #1:

DECLARE @FullName varchar(25)
SET @FullName = ‘ Jose Chinchilla ‘ — (notice spaces before and after the full name)
SELECT LEN(@FullName) –Result=>16

LEN will only count leading spaces and spaces in between the string but will not count trailing spaces.

Example #2:


DATALENGTH will count spaces in between and both leading and trailing spaces as well.

Using LTRIM and RTRIM to remove leading and trailing spaces

DECLARE @FirstName varchar(25)
SET @FirstName = ‘ Jose ‘; — (notice space before and after the word Jose)
SELECT @FirstName
–Result=> _Jose_  — (the underscore characters ‘_’ represent a blank space for clarification purposes, no actual underscores will show) 
–Result=> Jose_  –(only leading space is removed, the underscore character ‘_’ represent a blank space for clarification purposes, no actual underscore will show)
–Result=> _Jose  — (only trailing space is removed, the underscore character ‘_’ represent a blank space for clarification purposes, no actual underscore will show)
–Result=> Jose  — (both leading and trailing spaces are removed)

By nesting LTRIM and RTRIM you get similar results as the TRIM function in Excel and other programming languages. Unfortunately, there is no TRIM function in T-SQL.

Using CHARINDEX to find the position of all spaces in a string

In order for CHARINDEX to work properly you need to declare the data type length. For example: DECLARE @EmailAddress varchar(100) instread of DECLARE @EmailAddress  varchar. The same applies to nvarchar, char and nchar. You may use varchar(max) and nvarchar(max).

It is important to understand that CHARINDEX will only return the position of the first instance of the character you are looking for, in this case a space or char(32). To continue looking for the rest of the positions where you have empty spaces in your @EmailAddress variable you would need to loop through the entire string until no more spaces are found.

DECLARE @EmailAddress varchar(100), @SpacePositions varchar(max), @PositionIndex int
SET @EmailAddress = ‘ jchinchilla @ sqljoe.com ‘ — (notice leading and trailing spaces and spaces before & after the @ sign)
SET @SpacePositions = ”
SET @PositionIndex = CHARINDEX(char(32),@EmailAddress)
WHILE @PositionIndex > 0
SET @SpacePositions =
    WHEN CHARINDEX(char(32),@EmailAddress,@PositionIndex+1) > 0
THEN @SpacePositions + CONVERT(varchar,@PositionIndex) + ‘, ‘
ELSE @SpacePositions + CONVERT(varchar,@PositionIndex)
SET @PositionIndex = CHARINDEX(char(32),@EmailAddress,@PositionIndex+1)
SELECT @SpacePositions as  SpacePositions
–Result=> 1, 13, 15, 26

Using REPLACE to find and remove all spaces in a string

REPLACE will allow you to substitute all spaces in a string with an empty string, thus removing all spaces in between characters. In the following example, all spaces represented by char(32) will be replaced with an empty string ”.

DECLARE @EmailAddress varchar(max)
SET @EmailAddress = ‘ jchinchilla @ sqljoe.com ‘ — (notice leading and traling spaces and spaces before and after the @ sign)
SELECT REPLACE(@EmailAddress, CHAR(32),”)
–Result=> jchinchilla@sqljoe.com –(all spaces have been removed)

Using REPLICATE to insert ‘n’ number of spaces in a string

SELECT  ‘A’ + REPLICATE(‘ ‘,5)  + ‘Z’
Result=> A_____Z  — (the underscore characters ‘_’ represent a blank space for clarification purposes, no actual underscores will show)
SELECT  ‘A’ + REPLICATE(char(32),5)  + ‘Z’
Result=> A_____Z  — (the underscore characters ‘_’ represent a blank space for clarification purposes, no actual underscores will show)

T-SQL LOWER(): Change an all uppercase string to lower case

The T-SQL LOWER() command allows you to change an uppercase string to a lowercase string.

For example, it will allow you to change the word HELLO to hello.

Example 1:

Declare @MyVar varchar(50);
Set @Myvar=’HELLO’;
Select LOWER(@MyVar)   => Output will be hello in lowercase.

You can use the T-SQL LOWER() command with other commands to Capitalize only the first letter of a word.

For example, change FLORIDA  to Florida.


DECLARE @MyVar varchar(50);

Since my string is of length 50, notice that I am selecting the first letter that is already in uppercase and concatenating with the rest 49 letters in lowercase starting with the second position in the string.

SSIS Foreach File Enumerator returns more files than expected by appending a wildcard (*) to the file mask

While working on a recent project for a customer that involved importing both Excel 97-2003 and Excel 2007/2010 files, I was a little surprised to discover that the Foreach Loop File Enumerator will return both *.xls and *.xlsx files even if you only specify to return *.xls files.

I tested this behaviour with similar results with other file formats as well. During my testing, I created three files:

  1. File_txt.txt
  2. File_txts.txts
  3. File_txtsy.txtsy

See the screenshot of the three test files created below:

Next, I created an SSIS Package with a Foreach Loop Container with Foreach File Enumerator as the enumerator type and  specified *.txt as the file mask. The file names read by the Foreach Loop Container are being assigned to a user variable called varFileName. Then, inside the Foreach Loop Container I added a simple VB Script Task that returns the value of the user variable varFileName inside a message box.

See the Foreach Loop Containter configurations below:

See the VB script inside the Script Task below: 

You would expect only file_txt.txt to be returned, but as it turns out all three files were returned as can bee seen on the screen captures for the message boxes below:

It looks like the Foreach File Enumerator appends an asterisk (*) at the end of the extension portion of the file mask you specify. This means, that specifying *.txt or *.xls is the same as specifying *.txt* or *.xls*. As an additional test, I executed the <dir> command in D.O.S. to see the results of both masks. The two commands executed are shown below along with the results:

Interestingly, we get the same result in D.O.S. if we specify *.txt or *.txt*. I assume then, that the Foreach Loop file enumeration behaviour may be bound to the D.O.S. output of the Operating System. The current version of D.O.S. on my Windows 7 machine is 6.1.7600. With the introduction of support for more than three letter extensions, this little issue might have been overlooked in D.O.S. for the <dir> command.

The only reference I found regarding this issue with SSIS and the For Each Loop Container was by Douglas Laudenschlager (Blog), technical writer for Microsoft on the SQL Server Integration Services documentation team. The blog post where he mentions this as a gotcha can be found here: http://dougbert.com/blogs/dougbert/archive/2008/06/16/excel-in-integration-services-part-1-of-3-connections-and-components.aspx

Douglas correctly expresses,

 There appears to be no way to specify, “Give me .xls but not .xlsx”.

So, if you require to only limit your control flow execution for files with a specific extension, as in Douglas’ example .xls but not .xlsx, then your alternative will be to assign to a separate variable the extension portion of the file name contained in the varFileName variable of my SSIS package above. Once you capture the file extension in a variable, you can use a precedence constraint to restrict further control fow task execution for files of a specific file extension.

In my case, I declared a variable called varFileExtension and added the following line to the existing Script Task in my example:

I can now use a precedence constraint to check if the value contained in my varFileExtension is equal to “txt” as follows:

 By specifying a precedence constraint that evaluates for the exact file extension I’m looking to work with, I can limit the rest of the execution for only these files. Furthermore, if I wanted to have separate control flow logics for files of type “.xls” and “.xlsx” for example, I can split my control flow using two precedence constraints. In such case I could change the code inside my script to include the last 4 characters instead of just three. My two precedence constraint expressions would look something like this then:

  1. For XLS files -> @[User::varFileExtension]==”.xls” (period included since we are assigning the last 4 characters now)
  2. For XLSX files -> @[User::varFileExtension]==”xlsx”

The SSIS package would look something like this now:


Differences between Merge and Union All transformations in SSIS

 What are the differences between Merge and Union All transformations in SSIS ?

 The first and most obvious difference is that Merge can only accept two datasets while Union All can accept more than two datasets for input. The second difference is that Merge requires both datasets to be sorted while Union All does not require sorted datasets. Both transformations are considered to be partially-blocking.

As can be seen on the following image, Union All can accept more than two datasets as input while Merge is limited to only two input datasets. Also, notice that for the Merge transformation, the datasets need to be sorted before they can be accepted as valid input.

For simplification purposes,  a Sort transformation was used. Keep in mind that the Sort transformation is a full blocking operation because it needs to read all the rows in the data flow (buffer) in order to sort the data. No data will be sent downstream until all rows have been read first by the Sort transformation. A better approach would be to sort the datasets with an ORDER BY T-SQL clause at the data source component.

%d bloggers like this: