<?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>SSIS Talk &#187; SQL Server 2008</title>
	<atom:link href="http://www.ssistalk.com/category/sql-server-2008/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ssistalk.com</link>
	<description>Random thoughts and experiences with SSIS, by Phil Brammer</description>
	<lastBuildDate>Wed, 01 Feb 2012 12:48:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Quick Tip: Error: 18456, Severity: 14, State: 38.</title>
		<link>http://www.ssistalk.com/2011/05/06/quick-tip-error-18456-severity-14-state-38/</link>
		<comments>http://www.ssistalk.com/2011/05/06/quick-tip-error-18456-severity-14-state-38/#comments</comments>
		<pubDate>Fri, 06 May 2011 15:01:53 +0000</pubDate>
		<dc:creator>Phil Brammer</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2008]]></category>

		<guid isPermaLink="false">http://www.ssistalk.com/?p=267</guid>
		<description><![CDATA[When trying to investigate the SQL error, &#8220;Error: 18456, Severity: 14, State: 38.&#8221; it can be frustrating when not a single log on the system will tell you what the actual problem is.  In the case of state 38 (16 or 27 prior to SQL 2008) this error means the database specified in the [...]]]></description>
			<content:encoded><![CDATA[<p>When trying to investigate the SQL error, &#8220;Error: 18456, Severity: 14, State: 38.&#8221; it can be frustrating when not a single log on the system will tell you what the actual problem is.  In the case of state 38 (16 or 27 prior to SQL 2008) this error means the database specified in the client connection does not exist, or is offline.  In a large shop with many various clients it can be hard to find out the source of the connection, so you&#8217;re option is to use the tools at your disposal.  </p>
<p>The SQL Error Log does not help much at all. Here&#8217;s what&#8217;s in the SQL Error log:<br />
2011-05-06 09:06:17.28 Logon       Error: 18456, Severity: 14, State: 38.<br />
2011-05-06 09:06:17.28 Logon       Login failed for user &#8216;DOMAIN\ssrs.service&#8217;. Reason: Failed to open the explicitly specified database. [CLIENT: 192.168.0.147]</p>
<p>The Windows Application log is not much help either.<br />
Login failed for user &#8216;DOMAIN\ssrs.service&#8217;. Reason: Failed to open the explicitly specified database. [CLIENT: 192.168.0.147]</p>
<p>In other words, useless for troubleshooting.  The way to obtain the database name the client is trying to connect to is to use SQL Server Profiler.</p>
<p>To set up SQL Server Profiler, connect to the SQL instance where the error is occuring and then track the following events:<br />
Errors and Warnings: User Error Message<br />
Security Audit: Audit Login Failed</p>
<p>For these two events, make sure you capture at least the following columns: ApplicationName, HostName, LoginName, SPID (required), StartTime, TextData (where the message text will be), Severity, State, ClientProcessID, and Error.</p>
<p><img src="http://www.ssistalk.com/SQL_login_failure_trace_config.png" alt="SQL Profiler Setup Screenshot" /></p>
<p>Then run the trace.  You&#8217;ll see the following data under the &#8220;User Error Message&#8221; event when the login failure occurs:<br />
Cannot open database &#8220;DatabaseName&#8221; requested by the login. The login failed.<br />
For the &#8220;Audit Login Failed&#8221; event you&#8217;ll see the following data:<br />
Login failed for user &#8216;BLUENE\ssrs.service&#8217;. Reason: Failed to open the explicitly specified database. [CLIENT: 192.168.0.147]</p>
<p>Using this information (and the rest of the info in the other columns you selected), you should be able to go to the source and identify which process is trying to connect to the specified database and take appropriate action.</p>
<p>If you&#8217;re interested in the other states that error 18456 can generate, please visit fellow MVP Aaron Bertrand&#8217;s <a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2011/01/14/sql-server-v-next-denali-additional-states-for-error-18456.aspx">page on this topic</a> for a very nice listing.  </p>
<p>Attached is the SQL Profiler Trace Template for SQL 2008 instances if you want to import it instead of manually configuring SQL Profiler.  To import the template, in SQL Server Profiler, go to File->Templates and select Import&#8230;</p>
<p><a href="http://www.ssistalk.com/SQL_Login_Failures_Profiler_Template.tdf">SQL_Login_Failures_Profiler_Template.tdf</a> (860 bytes)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ssistalk.com/2011/05/06/quick-tip-error-18456-severity-14-state-38/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
<enclosure url="http://www.ssistalk.com/SQL_Login_Failures_Profiler_Template.tdf" length="860" type="audio/mpeg" />
		</item>
		<item>
		<title>SSIS &#8211; Export all SSIS packages from msdb</title>
		<link>http://www.ssistalk.com/2011/03/14/ssis-export-all-ssis-packages-from-msdb/</link>
		<comments>http://www.ssistalk.com/2011/03/14/ssis-export-all-ssis-packages-from-msdb/#comments</comments>
		<pubDate>Mon, 14 Mar 2011 22:02:36 +0000</pubDate>
		<dc:creator>Phil Brammer</dc:creator>
				<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SSIS]]></category>
		<category><![CDATA[SSIS Data flow]]></category>

		<guid isPermaLink="false">http://www.ssistalk.com/?p=258</guid>
		<description><![CDATA[So, in response to Jamie Thomson&#8217;s article on extracting all SSIS packages from msdb, I also wanted to show how this can be done from within SSIS itself.  It&#8217;s very straightforward, and uses a data flow component you may not be familiar with: Export Column.

First, setup four package level variables:
FilePath &#8211; string
SSISFolderFilePath &#8211; string
SSISFolderName [...]]]></description>
			<content:encoded><![CDATA[<p>So, in response to Jamie Thomson&#8217;s <a href="http://sqlblog.com/blogs/jamie_thomson/archive/2011/02/02/export-all-ssis-packages-from-msdb-using-powershell.aspx">article</a> on extracting all SSIS packages from msdb, I also wanted to show how this can be done from within SSIS itself.  It&#8217;s very straightforward, and uses a data flow component you may not be familiar with: <a href="http://technet.microsoft.com/en-us/library/ms139818.aspx">Export Column</a>.</p>
<p><span id="more-258"></span></p>
<p>First, setup four package level variables:<br />
FilePath &#8211; string<br />
SSISFolderFilePath &#8211; string<br />
SSISFolderName &#8211; string<br />
SSISFolders &#8211; object</p>
<p><strong>FilePath</strong> should be set to the location where you want to store the packages.  Include the trailing slash, and ensure that the location exists.<br />
<strong>SSISFolderFilePath</strong> should be set to evaluate an expression (EvaluateAsExpression = TRUE), and its expression should be:<br />
@[User::FilePath] +  @[User::SSISFolderName]</p>
<p>Then create a connection manager object that points to your MSDB database where you want to extract from.  If you want this to be dynamic, perhaps to archive ALL SSIS packages in your company, then this could be made a dynamic connection manager object (by using expressions) and you iterate over each server.  For now, we&#8217;re only going to use one server.</p>
<p>Once these are setup, the rest is point and click, pretty much.  Add an Execute SQL Task to the control flow, and configure it so that it returns a full resultset.  See below.</p>
<p><img src="http://www.ssistalk.com/ssis_extractPackages001.png" alt="Execute SQL Task" /></p>
<p><img src="http://www.ssistalk.com/ssis_extractPackages002.png" alt="Execute SQL Task 2" /></p>
<p>The query for the Execute SQL Task is:<br />
<code>
<pre>
SELECT foldername
  FROM dbo.sysssispackagefolders folders
 WHERE EXISTS (SELECT NULL
                 FROM dbo.sysssispackages pkg
                WHERE pkg.folderid = folders.folderid)
</pre>
<p></code></p>
<p>*Note &#8211; the above SQL only assumes a flat directory structure.  If you have subdirectories in MSDB, you can use a recursive CTE to create a hierarchy resultset.</p>
<p>With the Execute SQL Task set up, you&#8217;ll have to <a href="http://consultingblogs.emc.com/jamiethomson/archive/2005/07/04/ssis-nugget_3a00_-execute-sql-task-into-an-object-variable-_2d00_-shred-it-with-a-foreach-loop.aspx">shred the results</a> using a Foreach Loop Container.  Inside the Foreach Loop Container, we will want to use a File System Task to create directories for our packages if they do not already exist.  The configuration for that is below:</p>
<p><img src="http://www.ssistalk.com/ssis_extractPackages003.png" alt="File System Task" /></p>
<p>Next, we have to create a data flow and attach it to the Foreach Loop Container.  The full control flow should resemble the next screenshot.</p>
<p><img src="http://www.ssistalk.com/ssis_extractPackages1.png" alt="Control Flow diagram" /></p>
<p>In the data flow, we have three components &#8211; OLE DB Source, Derived Column, and the Export Column transformation.  Connect the OLE DB source to your connection manager object, and use the following query against MSDB:<br />
<code>
<pre>
SELECT folder.foldername,
       pkg.name,
       pkg.packagedata
  FROM dbo.sysssispackages pkg
  JOIN dbo.sysssispackagefolders folder
    ON pkg.folderid = folder.folderid
</pre>
<p></code></p>
<p>Then, configure the Derived Column component so that it creates one new column, FullFilePath.  The following is the expression to use:<br />
<code>
<pre>
(DT_WSTR,500)(@[User::FilePath] + foldername + "\\" + name + ".dtsx")
</pre>
<p></code></p>
<p>Then configure the Export Column transformation as the following screenshot illustrates:</p>
<p><img src="http://www.ssistalk.com/ssis_extractPackages004.png" alt="Export Column configuration" /></p>
<p>The final data flow should look like the following:</p>
<p><img src="http://www.ssistalk.com/ssis_extractPackages005.png" alt="Data flow diagram" /></p>
<p>The only thing left to do is execute the package.  Navigate to the location defined by the FilePath package variable and you should see a directory structure resembling that in MSDB with all of the SSIS packages saved.</p>
<p><img src="http://www.ssistalk.com/ssis_extractPackages006.png" alt="File contents" /></p>
<p>If you wish to download the full SSIS package, here you go: <a href="http://www.ssistalk.com/ExportSSISPackages.dtsx">http://www.ssistalk.com/ExportSSISPackages.dtsx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ssistalk.com/2011/03/14/ssis-export-all-ssis-packages-from-msdb/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>SSIS 2008 &#8211; Cannot Show Visual Studio 2008 Tools for Applications error</title>
		<link>http://www.ssistalk.com/2010/05/28/ssis-2008-cannot-show-visual-studio-2008-tools-for-applications-error/</link>
		<comments>http://www.ssistalk.com/2010/05/28/ssis-2008-cannot-show-visual-studio-2008-tools-for-applications-error/#comments</comments>
		<pubDate>Fri, 28 May 2010 19:40:11 +0000</pubDate>
		<dc:creator>Phil Brammer</dc:creator>
				<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SSIS]]></category>

		<guid isPermaLink="false">http://www.ssistalk.com/?p=236</guid>
		<description><![CDATA[Should you come across this error message, &#8220;cannot show visual studio 2008 tools for applications&#8221;, you may have to clean up your VSTA environment.
You may also have the following additional error message:
The System Cannot Find The File Specified 
Here&#8217;s how to fix it, thanks to Silviu Guea, Microsoft. 
Create a batch file with the following [...]]]></description>
			<content:encoded><![CDATA[<p>Should you come across this error message, &#8220;cannot show visual studio 2008 tools for applications&#8221;, you may have to clean up your VSTA environment.</p>
<p>You may also have the following additional error message:<br />
<em>The System Cannot Find The File Specified</em> </p>
<p>Here&#8217;s how to fix it, thanks to <a href="http://social.msdn.microsoft.com/Forums/en-US/sqlintegrationservices/thread/e5337b0c-7f70-4603-859e-fbc7d0cf1c37">Silviu Guea</a>, Microsoft. </p>
<p>Create a batch file with the following code.  Execute it.  Ignore any errors.  Try again.  If it doesn&#8217;t work, you may have to contact Microsoft support or try many uninstall/reinstall combinations.  For me, this worked the first time I tried it.  Finally, the code:</p>
<pre><code>
@rem start batch file
@rem delete the VSTA registry cache from the current user
REG DELETE HKCU\Software\Microsoft\VSTA /f
REG DELETE HKCU\Software\Microsoft\VSTAHost\SSIS_ScriptTask /f
REG DELETE HKCU\Software\Microsoft\VSTAHost\SSIS_ScriptComponent /f

@rem delete the VSTA registration cache for SSIS script task and data flow script component
REG DELETE HKLM\Software\Microsoft\VSTAHost\SSIS_ScriptTask /f
REG DELETE HKLM\Software\Microsoft\VSTAHost\SSIS_ScriptComponent /f

@rem delete the cached files from the HDD
rd /s /q "%AppData%\Microsoft\VSTA"
rd /s /q "%AppData%\Microsoft\VSTAHost\SSIS_ScriptTask"
rd /s /q "%AppData%\Microsoft\VSTAHost\SSIS_ScriptComponent"

rd /s /q "%USERPROFILE%\Local Settings\Application Data\VSTA"
rd /s /q "%USERPROFILE%\Local Settings\Application Data\VSTAHost\SSIS_ScriptTask"
rd /s /q "%USERPROFILE%\Local Settings\Application Data\VSTAHost\SSIS_ScriptComponent"

@rem re-generate the VSTA files for SSIS script task and component
"%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\vsta.exe" /hostid SSIS_ScriptTask /setup
"%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\vsta.exe" /hostid SSIS_ScriptComponent /setup

@rem end batch file
</code></pre>
<p>Download file here: <a href="http://www.ssistalk.com/vsta_cleanup.txt">vsta_cleanup.txt</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ssistalk.com/2010/05/28/ssis-2008-cannot-show-visual-studio-2008-tools-for-applications-error/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Be careful with sp_configure</title>
		<link>http://www.ssistalk.com/2010/05/24/be-careful-with-sp_configure/</link>
		<comments>http://www.ssistalk.com/2010/05/24/be-careful-with-sp_configure/#comments</comments>
		<pubDate>Mon, 24 May 2010 14:50:44 +0000</pubDate>
		<dc:creator>Phil Brammer</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>

		<guid isPermaLink="false">http://www.ssistalk.com/?p=234</guid>
		<description><![CDATA[For those of you that work extensively with sys.dm_exec_query_stats and associated plan cache DMVs, be aware that altering the server&#8217;s &#8216;max degree of parallelism&#8217; setting will flush the query plan cache.
You may see this message in your server&#8217;s SQL Log file:
&#8220;SQL Server has encountered 1 occurrence(s) of cachestore flush for the &#8216;SQL Plans&#8217; cachestore (part [...]]]></description>
			<content:encoded><![CDATA[<p>For those of you that work extensively with sys.dm_exec_query_stats and associated plan cache DMVs, be aware that altering the server&#8217;s &#8216;max degree of parallelism&#8217; setting will flush the query plan cache.</p>
<p>You may see this message in your server&#8217;s SQL Log file:<br />
&#8220;SQL Server has encountered 1 occurrence(s) of cachestore flush for the &#8216;SQL Plans&#8217; cachestore (part of plan cache) due to some database maintenance or reconfigure operations.&#8221;</p>
<p>In the case of MAXDOP changing, if you look before the above event happened, you should see that MAXDOP was changed and hence caused the flush.</p>
<p>This makes sense.  If you are changing the MAXDOP setting, all current query plans are worthless as they&#8217;re out of date with respect to this parameter.  Some plans may now be able to benefit from parallelism, whereas before they could not.  Or if constraining MAXDOP, some parallel plans may not be able to work anymore.  (Or some combination thereof.)  The easiest way to rectify this issue is to simply flush the plan cache and let all plans recompile at their next execution.</p>
<p>A common situation for changing MAXDOP could be for maintenance operations, where during normal operations MAXDOP is constrained to 1, yet while doing weekly work during a maintenance window the DBAs may elect to set MAXDOP to 0 (unrestricted).  </p>
<p>So, when you&#8217;re scratching your head wondering where your plan cache went, it could be due to administrative tasks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ssistalk.com/2010/05/24/be-careful-with-sp_configure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSIS 2008 &#8211; Beware of incorrect version stamp in SSMS</title>
		<link>http://www.ssistalk.com/2010/01/04/ssis-2008-beware-of-incorrect-version-stamp-in-ssms/</link>
		<comments>http://www.ssistalk.com/2010/01/04/ssis-2008-beware-of-incorrect-version-stamp-in-ssms/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 19:25:29 +0000</pubDate>
		<dc:creator>Phil Brammer</dc:creator>
				<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SSIS]]></category>

		<guid isPermaLink="false">http://www.ssistalk.com/?p=196</guid>
		<description><![CDATA[There is a bug where even if you have applied a patch or service pack to SSIS 2008, the version listed next to the &#8220;Integration Services&#8221; service in Management Studio continues to show 10.0.1600, which is the version number for RTM.
As always, if you are unsure, it is best to determine the actual version by [...]]]></description>
			<content:encoded><![CDATA[<p>There is a <a href="https://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=422562">bug</a> where even if you have applied a patch or service pack to SSIS 2008, the version listed next to the &#8220;Integration Services&#8221; service in Management Studio continues to show 10.0.1600, which is the version number for RTM.</p>
<p>As always, if you are unsure, it is best to determine the actual version by looking at the files themselves, ie. dtexec.exe, or by confirming the version number in BIDS via Help->About.</p>
<p>While this isn&#8217;t a big deal, it is an annoyance.  I&#8217;ve got the question out to the product team for their response, so stay tuned for more information as it becomes available.</p>
<p>EDIT &#8211; Please see <a href="http://blogs.msdn.com/mattm/">Matt Masson</a>&#8217;s (SSIS Product Team) comments below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ssistalk.com/2010/01/04/ssis-2008-beware-of-incorrect-version-stamp-in-ssms/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SSIS &#8211; Avoiding the Sort Components</title>
		<link>http://www.ssistalk.com/2009/09/17/ssis-avoiding-the-sort-components/</link>
		<comments>http://www.ssistalk.com/2009/09/17/ssis-avoiding-the-sort-components/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 15:38:17 +0000</pubDate>
		<dc:creator>Phil Brammer</dc:creator>
				<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SSIS]]></category>
		<category><![CDATA[SSIS Data flow]]></category>

		<guid isPermaLink="false">http://www.ssistalk.com/?p=170</guid>
		<description><![CDATA[When using a Merge or Merge Join component in a data flow, your incoming data is required to be sorted.  While it may be easy to drop a Sort component into your data flow, it may make more sense to perform the sort in your source query (if you are using a source such [...]]]></description>
			<content:encoded><![CDATA[<p>When using a Merge or Merge Join component in a data flow, your incoming data is required to be sorted.  While it may be easy to drop a Sort component into your data flow, it may make more sense to perform the sort in your source query (if you are using a source such as an OLE DB Source component).</p>
<p>If you decide to use an ORDER BY in your source and want to tell the SSIS Data Flow that your data is sorted, follow the below steps:</p>
<p><span id="more-170"></span></p>
<p>First, ensure that your data is being sorted with the ORDER BY clause.  Make note of which column(s) are in the sort and their positions.</p>
<p>Second, open the Advanced Editor for the OLE DB Source component by right-clicking on the OLE DB Source and selecting &#8220;Show Advanced Editor&#8230;&#8221;   </p>
<p>Then, click on the &#8220;Input and Output Properties&#8221; tab.  </p>
<p>Then highlight the &#8220;OLE DB Source Output Properties&#8221; branch and set the &#8220;IsSorted&#8221; property to True.</p>
<p><img src="http://www.ssistalk.com/OLE_DB_Source_IsSorted_1.png" alt="IsSorted = True" /></p>
<p>Next, expand the &#8220;OLE DB Source Output Properties&#8221; branch.  From here, select the first column under &#8220;Output Columns&#8221; that corresponds to the first column in your ORDER BY clause.  Set its &#8220;SortKeyPosition&#8221; property to the number 1.</p>
<p><img src="http://www.ssistalk.com/OLE_DB_Source_IsSorted_2.png" alt="SortKeyPosition" /></p>
<p>Repeat the last step for each column in your ORDER BY clause, advancing the SortKeyPosition by one each time.  (1,2,3,&#8230;)</p>
<p>That&#8217;s it.  Now the SSIS Data Flow will understand and acknowledge that the incoming data is sorted and will not require a Sort Component between the source and a Merge Join component, for instance.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ssistalk.com/2009/09/17/ssis-avoiding-the-sort-components/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>SQL Server 2008 &#8211; Maintenance Plans and SSIS Requirements</title>
		<link>http://www.ssistalk.com/2009/08/25/sql-server-maintenance-plans-and-ssis-requirements/</link>
		<comments>http://www.ssistalk.com/2009/08/25/sql-server-maintenance-plans-and-ssis-requirements/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 21:26:46 +0000</pubDate>
		<dc:creator>Phil Brammer</dc:creator>
				<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SSIS]]></category>

		<guid isPermaLink="false">http://www.ssistalk.com/?p=148</guid>
		<description><![CDATA[For those of you that wish to execute maintenance plans on a server and do not wish to have SSIS installed on said server, you will run into issues if you are on an RTM version of 2008 (version 10.0.1600).  
The specific error message is &#8220;The SQL Server Execute Package Utility requires Integration Services [...]]]></description>
			<content:encoded><![CDATA[<p>For those of you that wish to execute maintenance plans on a server and do not wish to have SSIS installed on said server, you will run into issues if you are on an RTM version of 2008 (version 10.0.1600).  </p>
<p>The specific error message is &#8220;The SQL Server Execute Package Utility requires Integration Services to be installed by one of these editions of SQL Server 2008: Standard, Enterprise, Developer, or Evaluation. To install Integration Services, run SQL Server Setup and select Integration Services.  The package execution failed.  The step failed.&#8221;</p>
<p>This constraint has been lifted in Service Pack 1 and Cumulative Update 3, each.  See: <a href="http://support.microsoft.com/kb/961126/">http://support.microsoft.com/kb/961126/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ssistalk.com/2009/08/25/sql-server-maintenance-plans-and-ssis-requirements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server &#8211; COUNT(expression) bug</title>
		<link>http://www.ssistalk.com/2009/07/24/sql-server-countexpression-bug/</link>
		<comments>http://www.ssistalk.com/2009/07/24/sql-server-countexpression-bug/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 15:45:28 +0000</pubDate>
		<dc:creator>Phil Brammer</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>

		<guid isPermaLink="false">http://www.ssistalk.com/?p=146</guid>
		<description><![CDATA[Starting with SQL Server 2005 RTM and through the latest SQL Server 2008 build at the time of this writing, there is a pretty nasty bug with respect to the COUNT(expression) function and its rule that when using an expression, it filters out NULLs in its count results.

Let me explain with a table called, NAME:

First_Name
John
Adam
Kris
NULL
Paula
NULL
George

&#8217;select [...]]]></description>
			<content:encoded><![CDATA[<p>Starting with SQL Server 2005 RTM and through the latest SQL Server 2008 build at the time of this writing, there is a pretty <a href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=380304">nasty bug</a> with respect to the COUNT(<em>expression</em>) function and its rule that when using an expression, it filters out NULLs in its count results.<br />
<span id="more-146"></span><br />
Let me explain with a table called, NAME:</p>
<p><code><br />
<strong>First_Name</strong><br />
John<br />
Adam<br />
Kris<br />
NULL<br />
Paula<br />
NULL<br />
George<br />
</code></p>
<p>&#8217;select count(*) from NAME&#8217; will return the value of 7.<br />
&#8217;select count(First_Name) from NAME&#8217; will return the value of 5 because there are two NULL values that are being excluded by rule.</p>
<p>So far so good.  The bug in this case shows up under conditions where you are COUNTing a column from what I&#8217;ll call a &#8220;grandchild table.&#8221;  In other words, if I have a table, SYS.OBJECTS, and it is joined to SYS.COLUMNS, which is then joined to another table (ANOTHERTABLE) that may or may not have matching SYS.COLUMNS in it and you are counting a column (eliminating NULLs) within ANOTHERTABLE, you may get erroneous results.</p>
<p>A working example is below, thanks to Ionel&#8217;s repro query included in the Connect bug submission:<br />
<code><br />
select o.object_id,<br />
       count(x.column_id) should_be_zero_always</p>
<p>  from sys.objects o</p>
<p>  left join sys.columns c<br />
    on o.object_id = c.object_id</p>
<p>  left join (<br />
             select column_id = 2<br />
              where 0 = 1<br />
            ) x<br />
    on c.column_id = x.column_id</p>
<p> group by o.object_id<br />
</code></p>
<p>You can run the above code in any database, and will likely see that 1s show up in the column titled, &#8220;should_be_zero_always.&#8221;</p>
<p>As you can see, the above query is going to be quite common where you do not want to filter results from the driving table and are forced to use an outer join.</p>
<p>The data behind the scenes looks like this:<br />
<code><br />
o.object_id c.object_id x.column_id cnt_returns_1_y_n<br />
1131151075  NULL        NULL        y<br />
1147151132  1147151132  1           n<br />
1147151132  1147151132  2           n<br />
1147151132  1147151132  3           n<br />
1147151132  1147151132  4           n<br />
1147151132  1147151132  5           n<br />
1147151132  1147151132  6           n<br />
1163151189  NULL        NULL        y<br />
1179151246  NULL        NULL        y<br />
</code></p>
<p>Where we have a NULL in c, x is also forced to be NULL (even though x is hardcoded to return an empty data set in the example above), COUNT(x.column_id) will return a 1 for this scenario, when it should be returning a zero.  </p>
<p>This works correctly in SQL Server 2000, I might add.</p>
<p>The bug is currently being tracked internally at Microsoft, and in theory, no future CTPs (which would be for releases beyond 2008) won&#8217;t have the issue, but there is no E.T.A. on when we&#8217;ll see a fix in 2005 or 2008.  Hopefully by the end of the year if we&#8217;re lucky and it doesn&#8217;t get de-prioritized.</p>
<p>I would encourage you to review the Connect bug submission and at least vote, but by all means, please leave your feedback on the issue while you are there.</p>
<p><a href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=380304">https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=380304</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ssistalk.com/2009/07/24/sql-server-countexpression-bug/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>SSMS &#8211; Trouble cleaning up your MRU server list in SSMS?</title>
		<link>http://www.ssistalk.com/2009/03/18/ssms-trouble-cleaning-up-your-mru-server-list-in-ssms/</link>
		<comments>http://www.ssistalk.com/2009/03/18/ssms-trouble-cleaning-up-your-mru-server-list-in-ssms/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 20:56:44 +0000</pubDate>
		<dc:creator>Phil Brammer</dc:creator>
				<category><![CDATA[SQL Server 2008]]></category>

		<guid isPermaLink="false">http://www.ssistalk.com/?p=136</guid>
		<description><![CDATA[Fellow MVP Aaron Bertrand has blogged about the MRU (Most Recently Used) server list in SSMS under SQL Server 2008 and how hard (and unsupported) it is to clean it up versus how it was under SQL Server 2005.    Please give that a read and head over to Connect to vote for [...]]]></description>
			<content:encoded><![CDATA[<p>Fellow MVP Aaron Bertrand has <a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/03/18/managing-the-mru-list-for-the-connect-to-server-dialog-in-ssms.aspx">blogged</a> about the MRU (Most Recently Used) server list in SSMS under SQL Server 2008 and how hard (and unsupported) it is to clean it up versus how it was under SQL Server 2005.    Please give that a read and head over to Connect to vote for his suggestion as you see fit.</p>
<p>(it&#8217;s easy [but still undocumented] under SQL Server 2005 &#8211; just delete the mru.dat file&#8230;)</p>
<p>Connect item: <a href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=424800">https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=424800</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ssistalk.com/2009/03/18/ssms-trouble-cleaning-up-your-mru-server-list-in-ssms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSIS &#8211; Using a Script Component as a Source</title>
		<link>http://www.ssistalk.com/2007/04/04/ssis-using-a-script-component-as-a-source/</link>
		<comments>http://www.ssistalk.com/2007/04/04/ssis-using-a-script-component-as-a-source/#comments</comments>
		<pubDate>Wed, 04 Apr 2007 15:09:39 +0000</pubDate>
		<dc:creator>Phil Brammer</dc:creator>
				<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SSIS Data flow]]></category>

		<guid isPermaLink="false">http://www.ssistalk.com/2007/04/04/ssis-using-a-script-component-as-a-source/</guid>
		<description><![CDATA[Just a quick tutorial on using a script component as a source&#8230;  Follow the link for screenshots.

First things first.  Add a script component to the data flow.  When prompted, select &#8220;Source&#8221; as the component type.  (click on images for full sized version)

Next, for clarity&#8217;s sake, I&#8217;ll rename the default output.  [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick tutorial on using a script component as a source&#8230;  Follow the link for screenshots.</p>
<p><span id="more-42"></span></p>
<p>First things first.  Add a script component to the data flow.  When prompted, select &#8220;Source&#8221; as the component type.  (click on images for full sized version)</p>
<p><a href="http://www.ssistalk.com/wp-content/uploads/2007/04/ssis_script_as_source.jpg" title="SSIS - Script Source Component 1"><img src="http://www.ssistalk.com/wp-content/uploads/2007/04/ssis_script_as_source.jpg" alt="SSIS - Script Source Component 1" height="282" width="434" /></a></p>
<p>Next, for clarity&#8217;s sake, I&#8217;ll rename the default output.  (An output simply contains a set of columns and will correlate to the green arrow on the data flow.  The more outputs you have, the more green arrows you can use.)  I&#8217;ll rename the default output, &#8220;Output 0&#8243; to &#8220;MyOutput.&#8221;</p>
<p><a href="http://www.ssistalk.com/wp-content/uploads/2007/04/ssis_script_as_source2.jpg" title="SSIS - Script Source Component 2"><img src="http://www.ssistalk.com/wp-content/uploads/2007/04/ssis_script_as_source2.jpg" alt="SSIS - Script Source Component 2" height="430" width="440" /></a></p>
<p>Next, I&#8217;ll add an output column called, &#8220;MyColumn&#8221; and its type will be an integer.  Be sure to change the type accordingly.</p>
<p><a href="http://www.ssistalk.com/wp-content/uploads/2007/04/ssis_script_as_source3.jpg" title="SSIS - Script Source Component 3"><img src="http://www.ssistalk.com/wp-content/uploads/2007/04/ssis_script_as_source3.jpg" alt="SSIS - Script Source Component 3" height="434" width="444" /></a></p>
<p>From here, we can edit the script by clicking on the script section on the left of the above window.  From there click on the &#8220;Design Script&#8230;&#8221; button.  Below is the setup:</p>
<p><a href="http://www.ssistalk.com/wp-content/uploads/2007/04/ssis_script_as_source4.jpg" title="SSIS - Script Source Component 4"><img src="http://www.ssistalk.com/wp-content/uploads/2007/04/ssis_script_as_source4.jpg" alt="SSIS - Script Source Component 4" /></a></p>
<p>Notice how when I type, I am automatically prompted for a list of available items to choose from.  One of them is the column I added previously.  Let&#8217;s pick the column and assign a value of 123 to it.  Full script below:</p>
<p>For SSIS 2005:</p>
<p><code>
<pre>Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper

Public Class ScriptMain
    Inherits UserComponent

    Public Overrides Sub CreateNewOutputRows()
        MyOutputBuffer.AddRow()
        MyOutputBuffer.MyColumn = 123
    End Sub

End Class</pre>
<p></code></p>
<p>For SSIS 2008, it&#8217;s a bit different:<br />
Visual Basic:<br />
<code>
<pre>
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper

&lt;Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute&gt; _
&lt;CLSCompliant(False)&gt; _
Public Class ScriptMain
    Inherits UserComponent

    Public Overrides Sub CreateNewOutputRows()
        Output0Buffer.AddRow()
        Output0Buffer.Column = 123
    End Sub

End Class
</pre>
<p></code></p>
<p>C#:<br />
<code>
<pre>
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;

[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{

  public override void CreateNewOutputRows()
    {
        Output0Buffer.AddRow();
        Output0Buffer.Column = 123;
    }

}
</pre>
<p></CODE></p>
<p>You can close the script and then click OK on the script component dialog box.  Now when you hook this source up to another component, you'll end up with one column with one row with a value of 123.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ssistalk.com/2007/04/04/ssis-using-a-script-component-as-a-source/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
	</channel>
</rss>

