<?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 2005</title>
	<atom:link href="http://www.ssistalk.com/category/sql-server-2005/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>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>SQL Server 2005 &#8211; How to introduce data corruption without trying</title>
		<link>http://www.ssistalk.com/2010/05/04/sql-server-2005-how-to-introduce-data-corruption-without-trying/</link>
		<comments>http://www.ssistalk.com/2010/05/04/sql-server-2005-how-to-introduce-data-corruption-without-trying/#comments</comments>
		<pubDate>Tue, 04 May 2010 20:51:17 +0000</pubDate>
		<dc:creator>Phil Brammer</dc:creator>
				<category><![CDATA[SQL Server 2005]]></category>

		<guid isPermaLink="false">http://www.ssistalk.com/?p=227</guid>
		<description><![CDATA[It is quite easy in SQL Server 2005 to accidentally (or intentionally, I suppose) create data corruption.  It&#8217;s best to just show via a demo, so here you go:
(Ref: http://www.sqlservercentral.com/Forums/Topic915058-2669-1.aspx.  Thanks, Paul White, for doing all of the work for this post.   )

-- In SQL Server 2005 only

-- fails
select round(0.5,0) 

-- [...]]]></description>
			<content:encoded><![CDATA[<p>It is quite easy in SQL Server 2005 to accidentally (or intentionally, I suppose) create data corruption.  It&#8217;s best to just show via a demo, so here you go:</p>
<p>(Ref: <a href="http://www.sqlservercentral.com/Forums/Topic915058-2669-1.aspx">http://www.sqlservercentral.com/Forums/Topic915058-2669-1.aspx</a>.  Thanks, Paul White, for doing all of the work for this post. <img src='http://www.ssistalk.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  )</p>
<pre><code>
-- In SQL Server 2005 only

-- fails
select round(0.5,0) 

-- 0.5 is cast as a numeric(1,1), which is used as the output type as well.
-- Since 0.5 rounds up to 1.0, this value is larger than a numeric(1,1) can store,
-- which is 0.9

-- works!
select round(0.5,0) as rnd
  into testround

-- view metadata of 'testround'
sp_help testround  

-- Observe that the 'rnd' column is defined as a numeric(1,1),
-- which technically means 0.9 is the max value

-- Now let's view the record:
select *
  from testround

-- WHAT?!  "Arithmetic Overflow"?  But, but, but the insert worked

-- Hmm, does this work? (Yes)
select cast(rnd as numeric(2,1)) as rnd
  from testround

-- Well, let's see what's going on here:

DBCC CHECKTABLE('testround') -- also catchable via DBCC CHECKDB, but not
                             -- with PHYSICAL_ONLY

/*
DBCC results for 'testround'.
Msg 2570, Level 16, State 3, Line 1
Page (1:1811349), slot 0 in object ID 2099048, index ID 0,
partition ID 72057594063028224, alloc unit ID 72057594096123904 (type
"In-row data"). Column "rnd" value is out of range for data type "numeric".
Update column to a legal value.
There are 1 rows in 2 pages for object "testround".
CHECKTABLE found 0 allocation errors and 1 consistency errors in table
'testround' (object ID 2099048).
DBCC execution completed. If DBCC printed error messages, contact your
system administrator.
*/

-- Okay, now let's see what's *REALLY* going on
DBCC TRACEON(3604)
GO

declare @db int
declare @filenumber int
declare @pagenumber int
set @db = db_id()
set @filenumber = 1       -- From DBCC output, adjust accordingly: Page (1:1811349)
set @pagenumber = 1811349 -- From DBCC output, adjust accordingly: Page (1:1811349)

DBCC PAGE(@db, @filenumber, @pagenumber, 3); -- 3 == full detail with ascii output 

-- Find the entry for slot 0 (according to the DBCC output above), note the out of range
-- value: "rnd = 1.0"

/*
Slot 0 Offset 0x60 Length 12

Record Type = PRIMARY_RECORD         Record Attributes =  NULL_BITMAP
Memory Dump @0x67EAC060

00000000:   10000900 010a0000 000100fe ††††††††††............             

Slot 0 Column 0 Offset 0x4 Length 5

rnd = 1.0
*/

-- Let's fix it

update testround
   set rnd = 0.9;
GO

-- Run CHECKTABLE again
DBCC CHECKTABLE('testround') -- success!  No issues.

-- Okay, example's over.  Turn off our TRACEON command and drop the table.

-- It is important to note that this does not work in 2008.  Whew.

DBCC TRACEOFF(3604)
GO

drop table testround;
GO
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ssistalk.com/2010/05/04/sql-server-2005-how-to-introduce-data-corruption-without-trying/feed/</wfw:commentRss>
		<slash:comments>0</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 &#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>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>

