<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Luke Hayler - SQL Server developer &#187; properties</title>
	<atom:link href="http://www.lukehayler.com/tag/properties/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lukehayler.com</link>
	<description>A blog about Integration services, Reporting services, and the things that interest me</description>
	<lastBuildDate>Fri, 06 Aug 2010 10:19:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setting the SQL Command Property using Expressions in SSIS 2005</title>
		<link>http://www.lukehayler.com/2010/03/setting-the-sql-command-property-using-expressions-in-ssis-2005/</link>
		<comments>http://www.lukehayler.com/2010/03/setting-the-sql-command-property-using-expressions-in-ssis-2005/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 12:15:00 +0000</pubDate>
		<dc:creator>Luke Hayler</dc:creator>
				<category><![CDATA[Integration Services]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[data sources]]></category>
		<category><![CDATA[expressions]]></category>
		<category><![CDATA[properties]]></category>
		<category><![CDATA[sql server 2005]]></category>
		<category><![CDATA[SSIS]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://www.lukehayler.com/2010/03/setting-the-sql-command-property-using-expressions-in-ssis-2005/</guid>
		<description><![CDATA[&#160;
OLE DB Source Adapter
The OLE DB source connection has several Access Modes:

Openrowset 
Openrowset From Variable 
SQL Command 
SQL Command From Variable 

For now, I am going to focus on the SQL Command options. Using the SQL Command Access Mode requires you to set the SqlCommand property (typing in your SQL query directly), effectively ‘hard coding’ [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<h4>OLE DB Source Adapter</h4>
<p>The OLE DB source connection has several <em>Access Modes:</em></p>
<ul>
<li>Openrowset </li>
<li>Openrowset From Variable </li>
<li>SQL Command </li>
<li>SQL Command From Variable </li>
</ul>
<p>For now, I am going to focus on the SQL Command options. Using the <em>SQL Command</em> Access Mode requires you to set the SqlCommand property (typing in your SQL query directly), effectively ‘hard coding’ the sql statement into the package. Using the <em>SQL Command From Variable</em> option allows you to set the SqlCommand property using a variable and subsequently by using an expression. </p>
<p><a href="http://www.lukehayler.com/wp-content/uploads/2010/03/SSIS2005_DataSource_AccessMode_Properties_OLEDBSource.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SSIS2005_DataSource_AccessMode_Properties_OLEDBSource" border="0" alt="SSIS2005_DataSource_AccessMode_Properties_OLEDBSource" src="http://www.lukehayler.com/wp-content/uploads/2010/03/SSIS2005_DataSource_AccessMode_Properties_OLEDBSource_thumb.png" width="560" height="268" /></a></p>
<p>&#160;</p>
<h4>Data Reader Source</h4>
<p>The Data Reader Source connection has only one Access Mode, and that is <em>SQL Command</em>. Don’t ask me why. At this level you can only set the SqlCommand property by typing in your query, or indeed, copy &amp; paste. </p>
<p><a href="http://www.lukehayler.com/wp-content/uploads/2010/03/SSIS2005_DataSource_AccessMode_Properties_DataReaderSource.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SSIS2005_DataSource_AccessMode_Properties_DataReaderSource" border="0" alt="SSIS2005_DataSource_AccessMode_Properties_DataReaderSource" src="http://www.lukehayler.com/wp-content/uploads/2010/03/SSIS2005_DataSource_AccessMode_Properties_DataReaderSource_thumb.png" width="560" height="272" /></a> </p>
<p>&#160;</p>
<h4>Using an Expression to set the SqlCommand Property</h4>
<p>“So then,” you ask, “how might I set the SqlCommand property for each of these Data Sources when it seems that I can’t?”. Here’s how. Let’s first concentrate on the OLE DB Source:</p>
<ol>
<li>Create a new Variable of type string and set your SQL statement </li>
<li>Open up the OLE DB Source and select the ‘SQL Command from Variable’ option </li>
<li>Now, select the the variable created in step 1 as the variable that contains the SQL statement </li>
</ol>
<p><a href="http://www.lukehayler.com/wp-content/uploads/2010/03/SSIS2005_DataAccessMode_OLEDBSource_Editor.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SSIS2005_DataAccessMode_OLEDBSource_Editor" border="0" alt="SSIS2005_DataAccessMode_OLEDBSource_Editor" src="http://www.lukehayler.com/wp-content/uploads/2010/03/SSIS2005_DataAccessMode_OLEDBSource_Editor_thumb.png" width="520" height="200" /></a> </p>
<p>At this point your OLE DB source is defined by the query that you have set in the Variable. We now need to create the expression that will define the query at runtime. We do this by navigating to the variable’s properties, setting the <em>EvaluateAsExpression </em>property to <strong>True</strong> and then configuring the expression in the <em>Expression</em> property.</p>
<p>Moving on to the Data Reader Source. With this adapter we only have the option of setting the SqlCommand directly. Or so I thought until recently. If you switch to the Control Flow design surface and select the Data Flow task that contains the Data Reader Source adapter, you will be able to set the SqlCommand using an expression.</p>
<ol>
<li>Select the Data Flow task to bring up its properties </li>
<li>Click the ellipsis (…) to bring up the Expression Editor </li>
<li>Select the [DataReader Source].[SqlCommand] Property </li>
<li>Set your expression. </li>
</ol>
<p><a href="http://www.lukehayler.com/wp-content/uploads/2010/03/SSIS2005_DataSource_AccessMode_Properties_DataFlowTask_Expressions.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SSIS2005_DataSource_AccessMode_Properties_DataFlowTask_Expressions" border="0" alt="SSIS2005_DataSource_AccessMode_Properties_DataFlowTask_Expressions" src="http://www.lukehayler.com/wp-content/uploads/2010/03/SSIS2005_DataSource_AccessMode_Properties_DataFlowTask_Expressions_thumb.png" width="560" height="262" /></a> </p>
<p><a href="http://www.lukehayler.com/wp-content/uploads/2010/03/SSIS2005_DataSource_AccessMode_Properties_DataFlowTask_ExpressionProperties.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SSIS2005_DataSource_AccessMode_Properties_DataFlowTask_ExpressionProperties" border="0" alt="SSIS2005_DataSource_AccessMode_Properties_DataFlowTask_ExpressionProperties" src="http://www.lukehayler.com/wp-content/uploads/2010/03/SSIS2005_DataSource_AccessMode_Properties_DataFlowTask_ExpressionProperties_thumb.png" width="560" height="382" /></a> </p>
<p>Using variables &amp; expressions to set your queries enables you to centralise your queries, use configuration files to set database connections and capture the queries you are running in logging operations.&#160;&#160; </p>
]]></content:encoded>
			<wfw:commentRss>http://www.lukehayler.com/2010/03/setting-the-sql-command-property-using-expressions-in-ssis-2005/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
