Jun 12 2008 5:24AM GMT
Posted by: mrdenny
Migration,
SSIS,
Beta,
SQL Server 2008,
SQL Server 2005
A ran across a bit of a problem when upgrading my SQL 2008 CTP 5 (November 2007) SSIS Packages to SQL 2008 RC0. Apparently Microsoft has changed the way that they handle the script tasks within the SSIS packages. Because of this when I edit all of the script tasks within my SSIS package the scripts were all blank.
The official fix from Microsoft is to install the older CTP version that you edited the scripts in on another machine and open the un-updated version of the SSIS package on that machine, and copy the code for the scripts into the RC0 version of the SSIS package.
The only object which I’ve had to do this on was a .NET Script Task. I had this problem when going from CTP 5 to CTP 6 as well as from CTP 5 to RC0. This will not effect migrating from SQL 2005 to SQL 2008 as SQL 2005 and SQL 2008 CTP 5 do not use the same scripting engine in the back end.
Denny
Jan 3 2008 8:00AM GMT
Posted by: mrdenny
SQL,
DataManagement,
XML,
SQL Server 2005,
SQL Server 2008,
SSIS
Receintly I was working on a project where I needed to use a foreach loop with an SSIS project, but couldn’t for the life of me get it to properly process the XML document which I was giving it. Well with some major work and digging I was able to get it working correctly, but it took me for ever to get all the little setting correct so I figured that I’d throw the info up here for anyone else who is looking for it.
Some background on what the process is that I’m working on. Basically I’ve got a table with catagorized data in it. I need to export all the data from the table info one file per catagory (don’t ask, I didn’t design it, I’ve just got to automate it; and it actually makes sence in the grant schem of things). Well I figured that the easiest way to do this was to use a foreach loop and give it an XML document with the list of catagories to process. (This was better than looping through and getting the next value from the database.)
So needless to say, I get started on my little process.
The query which I’m using within an Execute SQL Task is below. The Execute SQL Task puts the XML data into an SSIS variable called v_CategoryList with a data type of string.
SELECT WebsiteBlockCategoryId as id
FROM dbo.WebsiteBlockCategory cat with (nolock)
where WebsiteBlockCategoryId <> 0
for XML AUTO
The XML document looks like this. (SSIS seams to be wrapping it within <ROOT></ROOT> tags for me which is why I’m not doing it my self.) My XML document is actually must longer than this, but you get the idea. It’s a very basic XML document.
<ROOT>
<cat id=”18″ />
<cat id=”19″ />
<cat id=”20″ />
<cat id=”21″ />
<cat id=”22″ />
<cat id=”23″ />
<cat id=”24″ />
<cat id=”25″ />
<cat id=”26″ />
<cat id=”27″ />
<cat id=”28″ />
</ROOT>
As you can see on the screenshot of the forloop properties I’ve set the source to be my variable and the EnumerationType to Element Collection. Since I know where the data is within the XML document I use DirectInput for both the outer and Inner XPath strings. For the Outer XPath string I’m using “//cat”. Because I’m not putting in the ROOT level name it doesn’t matter what gets put in there as long as there is a parent level. For the Inner XPath string I’ve got the Element name with an @ sign in front of it “@id”.

Over on the Variables page of the UI I’ve got my v_CategoryId variable mapped to Index 0 of my document. If you need to output more than one element from your XML document set your Inner XPath to “*”. This “should” allow you to bring back all the elements and refer to them by index number starting with 0. I havn’t actually tried this, as I’ve always only needed a single element hense the “should”.

And to think, that little thing took me a couple of days to get working right. I can only imagine trying to do this in SQL 2000 and DTS.
Denny