<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>SSIS Team Blog : Execute SQL Task</title><link>http://blogs.msdn.com/mattm/archive/tags/Execute+SQL+Task/default.aspx</link><description>Tags: Execute SQL Task</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Capture PRINT messages from a stored procedure</title><link>http://blogs.msdn.com/mattm/archive/2007/09/13/capture-print-messages-from-a-stored-procedure.aspx</link><pubDate>Thu, 13 Sep 2007 19:28:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4896296</guid><dc:creator>mmasson</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/mattm/comments/4896296.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mattm/commentrss.aspx?PostID=4896296</wfw:commentRss><description>&lt;p&gt;I recently helped with a customer issue where they had a long running stored procedure which output status messages periodically using PRINT statements. They wanted to capture these statements and output them into the SSIS log. Unfortunately, the Execute SQL Task doesn't support this (it's something we're considering for the future), but it's fairly easy to do through a script task. &lt;/p&gt; &lt;p&gt;Our stored procedure:&lt;/p&gt; &lt;div&gt; &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;PROCEDURE&lt;/span&gt; SPWithPrint&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;AS&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;BEGIN&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;print&lt;/span&gt; &lt;span style="color: #006080"&gt;'very important status information...'&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;END&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Our script:&lt;/p&gt;
&lt;div&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; Main()&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; conn &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; SqlConnection(&lt;span style="color: #006080"&gt;"server=(local);Integrated Security=SSPI;database=Test"&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;AddHandler&lt;/span&gt; conn.InfoMessage, &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; SqlInfoMessageEventHandler(&lt;span style="color: #0000ff"&gt;AddressOf&lt;/span&gt; OnInfoMessage)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;     conn.Open()&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; cmd &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; SqlCommand()&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;     cmd.Connection = conn&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;     cmd.CommandType = CommandType.StoredProcedure&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;     cmd.CommandText = &lt;span style="color: #006080"&gt;"[SPWithPrint]"&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt;     cmd.ExecuteNonQuery()&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  14:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  15:&lt;/span&gt;     conn.Close()&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  16:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  17:&lt;/span&gt;     Dts.TaskResult = Dts.Results.Success&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  18:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  19:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  20:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  21:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; OnInfoMessage(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; args &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.Data.SqlClient.SqlInfoMessageEventArgs)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  22:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; sqlEvent &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; System.Data.SqlClient.SqlError&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  23:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;For&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Each&lt;/span&gt; sqlEvent &lt;span style="color: #0000ff"&gt;In&lt;/span&gt; args.Errors&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  24:&lt;/span&gt;         Dts.Events.FireInformation(sqlEvent.Number, sqlEvent.Procedure, sqlEvent.Message, &lt;span style="color: #006080"&gt;""&lt;/span&gt;, 0, &lt;span style="color: #0000ff"&gt;False&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  25:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;Next&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  26:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The print statements return the messages as InfoMessage events, which we catch with our handler and turn into SSIS information events.&lt;/p&gt;
&lt;p&gt;When we run the package, we can see the message from the stored procedure in our progress window...&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mattm/WindowsLiveWriter/CapturePRINTmessagesfromastoredprocedure_B5E0/image_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="167" alt="image" src="http://blogs.msdn.com/blogfiles/mattm/WindowsLiveWriter/CapturePRINTmessagesfromastoredprocedure_B5E0/image_thumb.png" width="244" border="0"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;We're looking into adding this functionality to the Execute SQL Task as well, but hopefully this is an acceptable alternative until then. &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4896296" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mattm/archive/tags/Execute+SQL+Task/default.aspx">Execute SQL Task</category><category domain="http://blogs.msdn.com/mattm/archive/tags/Script+Task/default.aspx">Script Task</category></item><item><title>Why can’t I store my BIGINT result in an Int64 variable?</title><link>http://blogs.msdn.com/mattm/archive/2007/04/18/why-can-t-i-store-my-bigint-result-in-an-int64-variable.aspx</link><pubDate>Thu, 19 Apr 2007 07:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2185726</guid><dc:creator>mmasson</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mattm/comments/2185726.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mattm/commentrss.aspx?PostID=2185726</wfw:commentRss><description>&lt;P&gt;The native providers (OLEDB, ODBC, ADO – ADO.NET doesn't have this problem) in the Execute SQL Task return the &lt;A href="http://msdn2.microsoft.com/en-us/library/ms187745.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms187745.aspx"&gt;BIGINT type&lt;/A&gt; as a String, and not an Int64 as you'd expect. Attempting to store the result in an Int64 variable gives you an error along the lines of: &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: Verdana"&gt;[Execute SQL Task] Error: An error occurred while assigning a value to variable "xxxx": "The type of the value being assigned to variable "xxxx" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object."&lt;/SPAN&gt; &lt;/P&gt;
&lt;P&gt;Although this behavior is documented in the &lt;A href="http://msdn2.microsoft.com/en-us/library/ms141003.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms141003.aspx"&gt;books online entry&lt;/A&gt;, we don't explain why it was done this way. Being somewhat new to the SSIS development team, I had to do some digging to find out for myself. It turns out that at the time this was implemented, there wasn't cross platform support for the 8-byte integer type (VT_I8/VT_UI8) in &lt;A href="http://msdn2.microsoft.com/en-us/library/ms221627.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms221627.aspx"&gt;VARIANTs&lt;/A&gt; -- specifically, on Windows 2000. Now that supporting Win2k is no longer an issue (for Katmai), we're free to change the behavior (while maintaining backwards compatibility for packages that are expecting the value as a string, of course). &lt;/P&gt;
&lt;P&gt;Expect this as a likely change in an upcoming release. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2185726" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mattm/archive/tags/Execute+SQL+Task/default.aspx">Execute SQL Task</category></item><item><title>Stored procedures with output parameters</title><link>http://blogs.msdn.com/mattm/archive/2006/11/08/stored-procedures-with-output-parameters.aspx</link><pubDate>Thu, 09 Nov 2006 03:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1041572</guid><dc:creator>mmasson</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/mattm/comments/1041572.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mattm/commentrss.aspx?PostID=1041572</wfw:commentRss><description>&lt;P&gt;When executing Stored Procedures with the Execute SQL Task, SSIS passes the statement to the underlying provider without parsing it. While efficient, the different ways of handling the input between the various providers can be a little frustrating. I was working on a couple of issues found in SP1, and realized that when dealing with stored procedures with output parameters, each provider wanted the SQL in a different format. &lt;/P&gt;
&lt;P&gt;I'll stick with a simple stored procedure example that returns a single value. &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;CREATE&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;PROC&lt;/SPAN&gt; intoutput &lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;@value &lt;SPAN style="COLOR: blue"&gt;INT&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;OUTPUT &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Courier New"&gt;AS &lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;SELECT&lt;/SPAN&gt; @value &lt;SPAN style="COLOR: gray"&gt;=&lt;/SPAN&gt; 10 &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;I want my Execute SQL Task to run the stored procedure, and store the result in a package variable (varInt). For different providers, you'll need to change two main fields – the SQL Statement, and the Parameter Name value on the Parameter Mapping page. &lt;/P&gt;
&lt;H3&gt;OLE DB &lt;/H3&gt;
&lt;P&gt;SQL Statement: exec intoutput ? output&lt;BR&gt;Parameter Name: 0 &lt;/P&gt;
&lt;P&gt;You should also set BypassPrepare to True, as the SQL can't be properly parsed if it contains a parameter marker. &lt;/P&gt;
&lt;P&gt;&lt;IMG height=331 alt="" src="http://mattmasson.members.winisp.net/img/110906_0007_Stored%20proc1.png" width=519 mce_src="http://mattmasson.members.winisp.net/img/110906_0007_Stored%20proc1.png"&gt; &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: #4f81bd"&gt;&lt;STRONG&gt;1 – OLE DB General &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;IMG height=55 alt="" src="http://mattmasson.members.winisp.net/img/110906_0007_Stored%20proc2.png" width=430 mce_src="http://mattmasson.members.winisp.net/img/110906_0007_Stored%20proc2.png"&gt; &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: #4f81bd"&gt;&lt;STRONG&gt;2 – OLE DB Parameter Mapping &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;ODBC &lt;/H3&gt;
&lt;P&gt;SQL Statement: {call intoutput (?)}&lt;BR&gt;Parameter Name: 1 &lt;/P&gt;
&lt;P&gt;The SQL statement for ODBC is very different than the others. You need to use "call" instead of "exec", and wrap the whole thing with curly braces. Also, the parameter numbering starts at 1 instead of 0. &lt;/P&gt;
&lt;P&gt;&lt;IMG height=331 alt="" src="http://mattmasson.members.winisp.net/img/110906_0007_Stored%20proc3.png" width=519 mce_src="http://mattmasson.members.winisp.net/img/110906_0007_Stored%20proc3.png"&gt; &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: #4f81bd"&gt;&lt;STRONG&gt;3 - ODBC General &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;IMG height=50 alt="" src="http://mattmasson.members.winisp.net/img/110906_0007_Stored%20proc4.png" width=447 mce_src="http://mattmasson.members.winisp.net/img/110906_0007_Stored%20proc4.png"&gt; &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: #4f81bd"&gt;&lt;STRONG&gt;4 - ODBC Parameter Mapping &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;ADO &lt;/H3&gt;
&lt;P&gt;SQL Statement: intoutput&lt;BR&gt;Parameter Name:&amp;lt;parameter name&amp;gt; &lt;/P&gt;
&lt;P&gt;For ADO, you can use the stored procedure name by itself, and set the IsQueryStoredProcedure attribute to True. For parameter name, you use the name you gave the parameter in the stored procedure (in this case, "value"). &lt;/P&gt;
&lt;P&gt;&lt;IMG height=331 alt="" src="http://mattmasson.members.winisp.net/img/110906_0007_Stored%20proc5.png" width=519 mce_src="http://mattmasson.members.winisp.net/img/110906_0007_Stored%20proc5.png"&gt; &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: #4f81bd"&gt;&lt;STRONG&gt;5 - ADO General &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;IMG height=58 alt="" src="http://mattmasson.members.winisp.net/img/110906_0007_Stored%20proc6.png" width=446 mce_src="http://mattmasson.members.winisp.net/img/110906_0007_Stored%20proc6.png"&gt; &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: #4f81bd"&gt;&lt;STRONG&gt;6 - ADO Parameter Mapping &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;ADO.NET &lt;/H3&gt;
&lt;P&gt;SQL Statement: intoutput&lt;BR&gt;Parameter Name:@&amp;lt;parameter name&amp;gt; &lt;/P&gt;
&lt;P&gt;ADO.NET is similar to ADO. Set IsQueryStoredProcedure to True, and set your statement to the name of the SP you want to execute. Like ADO, you need to use the name of the parameter in the stored procedure for the Parameter Name column, prefixed with @ (in this case, "@value"). Note: The parameter mapping seems to work without the use of the @ sign, but I'm not sure if that works for all providers. &lt;/P&gt;
&lt;P&gt;&lt;IMG height=331 alt="" src="http://mattmasson.members.winisp.net/img/110906_0007_Stored%20proc7.png" width=519 mce_src="http://mattmasson.members.winisp.net/img/110906_0007_Stored%20proc7.png"&gt; &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: #4f81bd"&gt;&lt;STRONG&gt;7 - ADO.NET General &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;IMG height=58 alt="" src="http://mattmasson.members.winisp.net/img/110906_0007_Stored%20proc8.png" width=422 mce_src="http://mattmasson.members.winisp.net/img/110906_0007_Stored%20proc8.png"&gt; &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: #4f81bd"&gt;&lt;STRONG&gt;8 - ADO.NET Parameter Mapping &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;Summary &lt;/H3&gt;
&lt;P&gt;Running stored procedures with the Execute SQL Task is tricky due to the differences in the way the providers handle the input SQL. The main differences are with the SQL Statement, and the Parameter Name value. The following table summarizes the differences (assumes a stored procedure of name StoredProc with a single output parameter named Param): &lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE class="" style="BORDER-COLLAPSE: collapse" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 87px"&gt;
&lt;COL style="WIDTH: 208px"&gt;
&lt;COL style="WIDTH: 147px"&gt;
&lt;COL style="WIDTH: 292px"&gt;&lt;/COLGROUP&gt;
&lt;TBODY vAlign=top&gt;
&lt;TR style="BACKGROUND: #4f81bd"&gt;
&lt;TD class="" style="PADDING-RIGHT: 7px; BORDER-TOP: #4f81bd 1pt solid; PADDING-LEFT: 7px; BORDER-LEFT: #4f81bd 1pt solid; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&lt;SPAN style="COLOR: white"&gt;&lt;STRONG&gt;Provider&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD class="" style="PADDING-RIGHT: 7px; BORDER-TOP: #4f81bd 1pt solid; PADDING-LEFT: 7px; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&lt;SPAN style="COLOR: white"&gt;&lt;STRONG&gt;SQL Statement&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD class="" style="PADDING-RIGHT: 7px; BORDER-TOP: #4f81bd 1pt solid; PADDING-LEFT: 7px; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&lt;SPAN style="COLOR: white"&gt;&lt;STRONG&gt;Parameter Name&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD class="" style="BORDER-RIGHT: #4f81bd 1pt solid; PADDING-RIGHT: 7px; BORDER-TOP: #4f81bd 1pt solid; PADDING-LEFT: 7px; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&lt;SPAN style="COLOR: white"&gt;&lt;STRONG&gt;Notes&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" style="PADDING-RIGHT: 7px; BORDER-TOP: medium none; PADDING-LEFT: 7px; BORDER-LEFT: #4f81bd 1pt solid; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&lt;STRONG&gt;OLE DB&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" style="PADDING-RIGHT: 7px; BORDER-TOP: medium none; PADDING-LEFT: 7px; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&amp;nbsp;exec StoredProc ? output&lt;/TD&gt;
&lt;TD class="" style="PADDING-RIGHT: 7px; BORDER-TOP: medium none; PADDING-LEFT: 7px; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&amp;nbsp;0&lt;/TD&gt;
&lt;TD class="" style="BORDER-RIGHT: #4f81bd 1pt solid; PADDING-RIGHT: 7px; BORDER-TOP: medium none; PADDING-LEFT: 7px; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&amp;nbsp;Set BypassPrepare to True&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" style="PADDING-RIGHT: 7px; PADDING-LEFT: 7px; BORDER-LEFT: #4f81bd 1pt solid; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&lt;STRONG&gt;ODBC&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" style="PADDING-RIGHT: 7px; PADDING-LEFT: 7px; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&amp;nbsp;{call StoredProc (?)}&lt;/TD&gt;
&lt;TD class="" style="PADDING-RIGHT: 7px; PADDING-LEFT: 7px; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&amp;nbsp;1&lt;/TD&gt;
&lt;TD class="" style="BORDER-RIGHT: #4f81bd 1pt solid; PADDING-RIGHT: 7px; PADDING-LEFT: 7px; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" style="PADDING-RIGHT: 7px; BORDER-TOP: medium none; PADDING-LEFT: 7px; BORDER-LEFT: #4f81bd 1pt solid; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&lt;STRONG&gt;ADO&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" style="PADDING-RIGHT: 7px; BORDER-TOP: medium none; PADDING-LEFT: 7px; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&amp;nbsp;StoredProc&lt;/TD&gt;
&lt;TD class="" style="PADDING-RIGHT: 7px; BORDER-TOP: medium none; PADDING-LEFT: 7px; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&amp;nbsp;Param&lt;/TD&gt;
&lt;TD class="" style="BORDER-RIGHT: #4f81bd 1pt solid; PADDING-RIGHT: 7px; BORDER-TOP: medium none; PADDING-LEFT: 7px; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&amp;nbsp;Set IsQueryStoredProcedure to True&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" style="PADDING-RIGHT: 7px; PADDING-LEFT: 7px; BORDER-LEFT: #4f81bd 1pt solid; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&lt;STRONG&gt;ADO.NET&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" style="PADDING-RIGHT: 7px; PADDING-LEFT: 7px; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&amp;nbsp;StoredProc&lt;/TD&gt;
&lt;TD class="" style="PADDING-RIGHT: 7px; PADDING-LEFT: 7px; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&amp;nbsp;@Param&lt;/TD&gt;
&lt;TD class="" style="BORDER-RIGHT: #4f81bd 1pt solid; PADDING-RIGHT: 7px; PADDING-LEFT: 7px; BORDER-BOTTOM: #4f81bd 1pt solid"&gt;&amp;nbsp;Set IsQueryStoredProcedure to True&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;For more info about the Execute SQL Task, you can check out the &lt;A href="http://msdn2.microsoft.com/en-us/library/ms141003.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms141003.aspx"&gt;books online entry&lt;/A&gt;, and the nice &lt;A href="http://www.sqlis.com/default.aspx?58" mce_href="http://www.sqlis.com/default.aspx?58"&gt;overview of the task&lt;/A&gt; on SQLIS.com. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1041572" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mattm/archive/tags/SSIS/default.aspx">SSIS</category><category domain="http://blogs.msdn.com/mattm/archive/tags/Stored+Procedures/default.aspx">Stored Procedures</category><category domain="http://blogs.msdn.com/mattm/archive/tags/Execute+SQL+Task/default.aspx">Execute SQL Task</category></item></channel></rss>