<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: SSIS Variables Do Not Like Varchar(MAX)</title>
	<atom:link href="http://blog.boxedbits.com/archives/6/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.boxedbits.com/archives/6</link>
	<description>( ... more specifically about BI with Microsoft products )</description>
	<lastBuildDate>Fri, 16 Jul 2010 18:42:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Peter</title>
		<link>http://blog.boxedbits.com/archives/6/comment-page-1#comment-3370</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Wed, 03 Feb 2010 10:52:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/6#comment-3370</guid>
		<description>Actually, I am trying to do just that with a 600 char varchar (from a varchar(1000) field) string, and it is failing.

The SQL-string is loading well in the Object Variable, together with some ID fields. When I display the Object contents the string is shown complete and correct. The next step is to loop through the rows in the Object variable. There, each row is read and fed to separate variables. This step is not working, the foreach loop can&#039;t seem to read the long string properly, and when I MsgBox the variable it just shows a blank.

Jamies blog posts are no longer available either (I saved hyperlinks instead of downloading the pages...).

Any ideas ?</description>
		<content:encoded><![CDATA[<p>Actually, I am trying to do just that with a 600 char varchar (from a varchar(1000) field) string, and it is failing.</p>
<p>The SQL-string is loading well in the Object Variable, together with some ID fields. When I display the Object contents the string is shown complete and correct. The next step is to loop through the rows in the Object variable. There, each row is read and fed to separate variables. This step is not working, the foreach loop can&#8217;t seem to read the long string properly, and when I MsgBox the variable it just shows a blank.</p>
<p>Jamies blog posts are no longer available either (I saved hyperlinks instead of downloading the pages&#8230;).</p>
<p>Any ideas ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Langston</title>
		<link>http://blog.boxedbits.com/archives/6/comment-page-1#comment-3143</link>
		<dc:creator>Langston</dc:creator>
		<pubDate>Wed, 08 Jul 2009 18:26:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/6#comment-3143</guid>
		<description>.ToString() doesn&#039;t work. See my post below for a solution.</description>
		<content:encoded><![CDATA[<p>.ToString() doesn&#8217;t work. See my post below for a solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Langston</title>
		<link>http://blog.boxedbits.com/archives/6/comment-page-1#comment-3142</link>
		<dc:creator>Langston</dc:creator>
		<pubDate>Wed, 08 Jul 2009 18:25:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/6#comment-3142</guid>
		<description>See my post below for solution.</description>
		<content:encoded><![CDATA[<p>See my post below for solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Langston</title>
		<link>http://blog.boxedbits.com/archives/6/comment-page-1#comment-3141</link>
		<dc:creator>Langston</dc:creator>
		<pubDate>Wed, 08 Jul 2009 18:24:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/6#comment-3141</guid>
		<description>@Tom VdP: You have to assign it to an Object variable because the string variable will not accept varchar(max) result sets. I found that the .ToString() method doesn&#039;t work after you save the result set to an SSIS object variable. All that does is return the data type, not the value of the string itself.

@Tom VdP: Rather than use a script task to execute the SQL, which is more extensive to code and less modular, I found a simpler approach.

To All,
Basically, you have to use a ForEach Loop to &quot;shred&quot; the object variable saved from the SQL Task. See here for details on how to do that (credit Jamie Thompson - SSIS guru): http://blogs.conchango.com/jamiethomson/archive/2005/07/04/SSIS-Nugget_3A00_-Execute-SQL-Task-into-an-object-variable-_2D00_-Shred-it-with-a-Foreach-loop.aspx

Once you have your varchar(max) results saved to the Object variable, you loop through it, which in some cases will be only once if all you needed was a single string value in the first place. In the loop&#039;s variable mappings, you map the results from the object variable to an SSIS string variable, and VIOLA! The string value from your varchar(max) result set is now saved to an SSIS string variable.

The strange part is that I do not know why the ForEach loop properly stores the string value of the varchar(max) result set to an SSIS string variable, but you cannot do it in a script task. But hey, this works, so I aint complaining. BTW, this workaround is confirmed in SSIS 2008, although I cannot imagine it would not work in 2005.</description>
		<content:encoded><![CDATA[<p>@Tom VdP: You have to assign it to an Object variable because the string variable will not accept varchar(max) result sets. I found that the .ToString() method doesn&#8217;t work after you save the result set to an SSIS object variable. All that does is return the data type, not the value of the string itself.</p>
<p>@Tom VdP: Rather than use a script task to execute the SQL, which is more extensive to code and less modular, I found a simpler approach.</p>
<p>To All,<br />
Basically, you have to use a ForEach Loop to &#8220;shred&#8221; the object variable saved from the SQL Task. See here for details on how to do that (credit Jamie Thompson &#8211; SSIS guru): <a href="http://blogs.conchango.com/jamiethomson/archive/2005/07/04/SSIS-Nugget_3A00_-Execute-SQL-Task-into-an-object-variable-_2D00_-Shred-it-with-a-Foreach-loop.aspx" rel="nofollow">http://blogs.conchango.com/jamiethomson/archive/2005/07/04/SSIS-Nugget_3A00_-Execute-SQL-Task-into-an-object-variable-_2D00_-Shred-it-with-a-Foreach-loop.aspx</a></p>
<p>Once you have your varchar(max) results saved to the Object variable, you loop through it, which in some cases will be only once if all you needed was a single string value in the first place. In the loop&#8217;s variable mappings, you map the results from the object variable to an SSIS string variable, and VIOLA! The string value from your varchar(max) result set is now saved to an SSIS string variable.</p>
<p>The strange part is that I do not know why the ForEach loop properly stores the string value of the varchar(max) result set to an SSIS string variable, but you cannot do it in a script task. But hey, this works, so I aint complaining. BTW, this workaround is confirmed in SSIS 2008, although I cannot imagine it would not work in 2005.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom VdP</title>
		<link>http://blog.boxedbits.com/archives/6/comment-page-1#comment-2752</link>
		<dc:creator>Tom VdP</dc:creator>
		<pubDate>Wed, 11 Mar 2009 19:45:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/6#comment-2752</guid>
		<description>Valentin, are you sure you need an Object variable ?  Anyway, try the .ToString() method, that should do it, I would say.</description>
		<content:encoded><![CDATA[<p>Valentin, are you sure you need an Object variable ?  Anyway, try the .ToString() method, that should do it, I would say.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom VdP</title>
		<link>http://blog.boxedbits.com/archives/6/comment-page-1#comment-2751</link>
		<dc:creator>Tom VdP</dc:creator>
		<pubDate>Wed, 11 Mar 2009 19:43:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/6#comment-2751</guid>
		<description>Indeed, the SSIS Exec SQL Task is too limited.  We ran into this limitation too and worked around it by using a Script Task to execute the SQL.  Strings in the Script Tasks are not limited to that silly 8000 characters limit.</description>
		<content:encoded><![CDATA[<p>Indeed, the SSIS Exec SQL Task is too limited.  We ran into this limitation too and worked around it by using a Script Task to execute the SQL.  Strings in the Script Tasks are not limited to that silly 8000 characters limit.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Valentin</title>
		<link>http://blog.boxedbits.com/archives/6/comment-page-1#comment-2744</link>
		<dc:creator>Valentin</dc:creator>
		<pubDate>Tue, 10 Mar 2009 04:43:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/6#comment-2744</guid>
		<description>I return it as varchar(max) and assign to Object variable.
How to then in VB script task get the string out of this object?
Convertsion of _ComObject to String is not permitted

Help</description>
		<content:encoded><![CDATA[<p>I return it as varchar(max) and assign to Object variable.<br />
How to then in VB script task get the string out of this object?<br />
Convertsion of _ComObject to String is not permitted</p>
<p>Help</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: smmcroberts</title>
		<link>http://blog.boxedbits.com/archives/6/comment-page-1#comment-1815</link>
		<dc:creator>smmcroberts</dc:creator>
		<pubDate>Fri, 10 Oct 2008 11:32:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/6#comment-1815</guid>
		<description>Thanks for the tip, but my string really is larger than 8,000 characters, which is why I was using varchar(max). Is there any way to get SSIS to handle this? Is the SSIS Exec SQL Task return String type really limited to 8,000 characters?</description>
		<content:encoded><![CDATA[<p>Thanks for the tip, but my string really is larger than 8,000 characters, which is why I was using varchar(max). Is there any way to get SSIS to handle this? Is the SSIS Exec SQL Task return String type really limited to 8,000 characters?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chaps</title>
		<link>http://blog.boxedbits.com/archives/6/comment-page-1#comment-1553</link>
		<dc:creator>chaps</dc:creator>
		<pubDate>Fri, 08 Aug 2008 15:21:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/6#comment-1553</guid>
		<description>Your post was really helpful.Thanks</description>
		<content:encoded><![CDATA[<p>Your post was really helpful.Thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>
