<?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>Aaron Lowe</title>
	<atom:link href="http://www.aaronlowe.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aaronlowe.net</link>
	<description>SELECT my.Thoughts FROM Vendoran.dbo.Brain my</description>
	<lastBuildDate>Fri, 23 Jul 2010 13:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Don&#8217;t Worry, I&#8217;ll Get To It</title>
		<link>http://www.aaronlowe.net/archive/2010/07/dont-worry-ill-get-to-it/</link>
		<comments>http://www.aaronlowe.net/archive/2010/07/dont-worry-ill-get-to-it/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 13:00:00 +0000</pubDate>
		<dc:creator>Aaron Lowe</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[VSDBPro]]></category>

		<guid isPermaLink="false">http://www.aaronlowe.net/archive/2010/07/dont-worry-ill-get-to-it/</guid>
		<description><![CDATA[Looking back you realized where you made your first mistake.&#160; You thought it would work out differently; in fact, you knew it would.&#160; Alas, you believed the lie. Wait, let’s back up: Sweat mars your brow as you start to feel panic set in.&#160; You reach for your mountain dew can and quickly put it [...]]]></description>
			<content:encoded><![CDATA[<p>Looking back you realized where you made your first mistake.&#160; You thought it would work out differently; in fact, you knew it would.&#160; Alas, you believed the lie. </p>
<p><i>Wait, let’s back up:</i></p>
<p>Sweat mars your brow as you start to feel panic set in.&#160; You reach for your mountain dew can and quickly put it down so no one will see your hand shaking (plus don’t want to spill a good dew). </p>
<p><i>Still need to back up further:</i></p>
<p>You were minding your own business watching a great <a href="http://www.sqlpass.org/">SQLPASS</a> webcast and thinking of how you were going to implement those cool things you learned.&#160; At least, that was until you got <a href="http://www.youtube.com/watch?v=Hj-qhIGTXdU">THE PHONECALL</a>.&#160; Your boss calls and says, “Hey there’s this project going on that is going to need some database help, I’ve told them you’re just the person to do it.&#160; So I’ve scheduled you in a conference call tomorrow morning first thing.&#160; Sounded pretty straight forward so should be no problem.” You then start downloading your brain to notepad and internet links so you don’t forget the <a href="http://www.sqlpass.org/">SQLPASS</a> presentation. </p>
<p>You come in the next day, get your morning Mountain Dew (hey it’s my story and I’m not much of a coffee drinker) and jump on the conference call.&#160;&#160;&#160; That is when you hear this: </p>
<p>“Glad you could join us; your boss said you were the best, so we’re expecting great things from you.&#160; What we need is a database to store the Excel documents we’ve been working on for the past year.&#160; We’ve just been emailing them around, so we’ll need to import the data and be able to create reports.&#160; I already spec’d it out in Access and don’t think it should take more than a week, but with you on here, it should take less time!&#160; This is good because we’re already committed to deadlines in about a month. I will email you the Excel documents, once you look and understand them we will talk later this afternoon to answer any questions you have. K, thanks, bye” </p>
<p>You start seeing visions of SSIS, SSRS and SQL go through your head and you’re wrapping your brain around everything that needs to be done, when you get the email: “Here’s a couple of the first type of spreadsheets, there are actually 3 different types of spreadsheets but it’s all related.&#160; Should be no problem for a wiz like you, huh? <img src='http://www.aaronlowe.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  When you’re ready for the rest, let us know and we can create a CD of them – think there’s about 300 or so.&#160; I forgot to mention on the call that while we have a deadline in a month, we promised to start getting reports out next week, so I’m really looking forward to seeing the reports this week.” </p>
<p>Sweat mars your brow as you start to feel panic set in.&#160; You reach for your mountain dew can and quickly put it down so no one will see your hand shaking (plus don’t want to spill a good dew).&#160;&#160; Then a thought creeps into your head, you initially reject it, and look around to make sure no one heard it, but as you think about it, the thought starts making sense and you start to smile.&#160; You now have the way to meet or possibly exceed the expectations and you can look like the hero.&#160; So you say to yourself, “Don’t worry, I’ll just import manually, create the code as I go to be quick, then I can go back and clean it up later” </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; </p>
<p>The above scenario is not that uncommon in our field.&#160; We are brought in as the experts and expected to produce things quickly.&#160; The business group does not know and possibly does not even care about everything we do. But, really, it is not their job, if they did, you would not have one.&#160; Things like code quality, code coverage, and security are your job, not theirs. </p>
<p>However, I am still seeing too many people try to be the hero by working around the clock or reducing code quality to meet the requirements as soon as possible.&#160; Let me refute some more common reasons: </p>
<p><b>I will have plenty of time…</b></p>
<p>The idea that you will all of a sudden have this huge amount of free time to do performance improvements, proper error handling, better naming conventions, etc. is a myth.&#160; More likely, you will be pulled onto another project and then someone will knock on your door in a year or two asking you to explain this really bad code they found.&#160; If on the other hand you are experiencing large blocks of free time, please send me a note as I might have some work for you.&#160; <em>Companies pay you to work, which is the opposite of having free time.</em></p>
<p><b>I’ll just do it this once…</b></p>
<p>If you put that kind of code out there, you will probably end up doing a lot of manual process/manipulation.&#160; This means when it is time to actually go-live, you scramble to get it all working, again reducing quality.&#160; I have often seen “While it’s in development I don’t have to worry about getting it scheduled.&#160; Oh that process didn’t work; I’ll just manually fix it.”&#160; <em>If you have to fix it manually in development, you will have to fix it manually in prod.</em></p>
<p><b>They just don’t understand</b></p>
<p>Our job should not just be seen as a cost center it should be seen as an asset.&#160; That does not mean we just produce great code/functionality, it means we help the business achieve the business goals.&#160; In other words, we work “with” not “for” the business.&#160; </p>
<p>Back in the Exchange 5.5 days, I did some work as a systems administrator.&#160; We discovered that some people were using mailboxes that had up to 500 MB in them, while the average was around 100; I researched best practices and did all this analysis.&#160; I finally brought the suggestion to my boss, “We should limit everyone’s mailbox to XX size that way we don’t have space issues” His response “This is obviously the way our people work and if it is, why we shouldn’t just invest in more space so they can continue to work that way?”&#160; </p>
<p>I had never considered the business, only the technology.&#160; When you just have technology on the brain and not the business or the people you come up with solutions for the technology. “My system would be perfect except for all those users” </p>
<p>Take the time to explain what you <i>need </i>to accomplish so you can create what they <i>want </i>you to accomplish.&#160; They want it sooner rather than later? Then reflect some of those decisions back to them, even empowering them to make some.&#160; “Yes I can get that really cool function out there this week, but everyone in the world will have access to it,&#160; With a couple more days I can also have it secure.&#160; Which would you like?”&#160; Of course, this means that you have to think more strategically about the project, which can be difficult at times.&#160; We all know how easy (and fun) it is to just jump in there and start producing code”.&#160; <em>Transparency is the key.</em></p>
<p><b>But I’m always having to change things</b></p>
<p>Realize that some refactoring will always be necessary. The days of going away for 6 months to create something and come back to do your big “<a href="http://www.youtube.com/watch?v=XBrz7zMg91k">ta-da</a>” are long gone.&#160; People want things faster with more agility so things can change as we go along.&#160;&#160;&#160; This means more pressure to produce faster, which means refactoring and adding additional functionality as you go.&#160; However ever line of code you write should be quality.&#160; I don’t know how many times I have seen Proof-of-Concepts (POCs) turn into the actual production system.&#160; Just because it is a POC from a business perspective does not mean that it should be a POC from a code quality perspective.&#160; I actually saw someone code up a textbook T-SQL injection (put the stored procedure parameter straight in the where clause without any validation), with the intention of fixing it later.&#160; <i>If it is wrong to do later, it is wrong to do now.</i></p>
<p>In the development world, there are many tools for code coverage, unit testing, refactoring, etc.&#160; While there are some tools out there like <a href="http://www.microsoft.com/visualstudio/en-us">VSDBPro</a> unit testing, <a href="http://www.dbproj.com/">VSDBPro</a> and <a href="http://www.red-gate.com/">Red Gate</a> refactoring, etc., the tools in the database world are not as mature.&#160; There is no IDE that forces white space or automatically documents for you.&#160; We do not have tools where we can just do a few clicks and have end-to-end tests. </p>
<p>However, that is no excuse to be a gunslinger and just shoot from the hip.&#160; We are professionals and should be creating professional code that is readable, documented and have a standard of quality. </p>
<p>If you are struggling with that, adopt a <a href="http://www.sqlservercentral.com/articles/Testing/66553/">Test Driven Development</a> (TDD) philosophy or something else that will force you to think about or do things better.&#160; </p>
<p>Or maybe it is taking you 5 minutes to figure out what is going on in a stored procedure you just wrote a couple days ago.&#160; If so, let’s be honest you failed in either code readability and/or documentation. No excuses, there are even <a href="http://www.wangz.net/pp/sqlformat.htm">good free tools</a> out there. Whitespaceisreallyagoodthing. </p>
<p><b>Code Quality, Code Readability and Code Documentation is Important</b></p>
]]></content:encoded>
			<wfw:commentRss>http://www.aaronlowe.net/archive/2010/07/dont-worry-ill-get-to-it/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Allow me to reintroduce myself</title>
		<link>http://www.aaronlowe.net/archive/2010/07/allow-me-to-reintroduce-myself/</link>
		<comments>http://www.aaronlowe.net/archive/2010/07/allow-me-to-reintroduce-myself/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 04:29:40 +0000</pubDate>
		<dc:creator>Aaron Lowe</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.aaronlowe.net/archive/2010/07/allow-me-to-reintroduce-myself/</guid>
		<description><![CDATA[Alright, alright, I haven’t posted in a long time (7 months or so).&#160; In my defense I have had some things going on.&#160; But someone has been bugging encouraging me to get back to it. I argued that I have better ROI spending time with them, when I was politely informed that I don’t really [...]]]></description>
			<content:encoded><![CDATA[<p>Alright, alright, I haven’t posted in a long time (7 months or so).&#160; In my defense I have had <a href="http://twitter.com/Vendoran/status/13360669671" target="_blank">some</a> <a href="http://twitter.com/Vendoran/status/17435870808" target="_blank">things</a> <a href="http://twitter.com/Vendoran/status/16970647907" target="_blank">going</a> <a href="http://twitter.com/Vendoran/status/16804029111" target="_blank">on</a>.&#160; But <a href="http://twitter.com/Vendoran/status/18371568419" target="_blank">someone</a> has been <strike>bugging</strike> encouraging me to get back to it. I argued that I have better ROI spending time with <a href="http://twitpic.com/1g5xg3" target="_blank">them</a>, when I was politely informed that I don’t <strong>really </strong>need the full 6 hours of sleep I attempt every night.&#160; So I’m typing this up at 11:30 pm while the rest of my family is asleep so please read quietly so as to not disturb anyone.</p>
<p>Now that I’m typing and you’re reading quietly, on to the reintroduction: <a href="http://twitter.com/Vendoran" target="_blank">here I am</a>, <a href="http://www.youtube.com/vendoran" target="_blank">over here to</a>, also mentioned <a href="http://www.brentozar.com/archive/2008/10/what-im-not-announcing-monday-yet-another-forum/" target="_blank">here</a> and <a href="http://blogs.lessthandot.com/index.php/ITProfessionals/EthicsIT/my-singing-not-so-good" target="_blank">here</a>.</p>
<p>As to why no activity lately, to be honest I have had a lot to say and I have a whole list of ideas for blog posts however as soon as I start to write one, my perfectionism comes into play and I never have time to create what I think would be a perfect post, so I don’t.&#160; I look up at what I don’t know and decide I don’t know enough, instead of looking down or around at what I do know to talk about.&#160; This is the beginning of the effort to change and just put some thoughts out there (for better of worse <img src='http://www.aaronlowe.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .&#160; </p>
<p>For those keeping score at home I’m still at <a href="http://www.magenic.com/" target="_blank">Magenic</a> and while a <a href="http://whitneyweaver.com/post/Changes-and-Announcements.aspx" target="_blank">couple</a> <a href="http://denglishbi.spaces.live.com/blog/cns!CD3E77E793DF6178!3498.entry" target="_blank">good</a> friends have left, we’re <a href="http://magenic.submit4jobs.com/" target="_blank">hiring</a>.&#160; In fact in the Chicago office we have had 3 people start in the last 2 weeks (including <a href="http://www.wendyverse.blogspot.com/" target="_blank">here</a>)! So if you are looking, hit me up and we’ll see what can be done.</p>
<p>Other than that, I’m still doing all things SQL Server from SSIS to Service Broker to CDC to Replication to CLR to encryption to SSRS to data modeling and of course VSDBPro.&#160; Basically the entire stack and oh by the way, still loving it!</p>
<p>For review this post had 3 purposes: </p>
<ol>
<li>Begin Momentum </li>
<li>Remind everyone I’m still around </li>
<li>Fulfill my promise to Ted </li>
</ol>
<p>Mission Accomplished!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aaronlowe.net/archive/2010/07/allow-me-to-reintroduce-myself/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SSIS CDC LSN Debugging nightmare second problem</title>
		<link>http://www.aaronlowe.net/archive/2009/12/ssis-cdc-lsn-debugging-nightmare-second-problem/</link>
		<comments>http://www.aaronlowe.net/archive/2009/12/ssis-cdc-lsn-debugging-nightmare-second-problem/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 09:00:00 +0000</pubDate>
		<dc:creator>Aaron Lowe</dc:creator>
				<category><![CDATA[2008]]></category>
		<category><![CDATA[CDC]]></category>
		<category><![CDATA[SSIS]]></category>

		<guid isPermaLink="false">/post/2009/12/18/SSIS-CDC-LSN-Debugging-nightmare-second-problem.aspx</guid>
		<description><![CDATA[Continuing the CDC debugging posts: Intro First Problem Now that I have the StartLSN and EndLSN I was ready to go.  Hit my breakpoint and the variables were set appropriately.  Woo-hoo! Then…wait a minute…what? vSQLQuery.Value = "SELECT " + " c.__$operation " + " , c.Column1 " + " , c.Column2 " + " , [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing the CDC debugging posts:</p>
<ul>
<li><a href="http://www.aaronlowe.net/archive/2009/12/ssis-cdc-lsn-debugging-nightmare-introduction/">Intro</a></li>
<li><a href="http://www.aaronlowe.net/archive/2009/12/ssis-cdc-lsn-debugging-nightmare-first-problem/">First Problem</a></li>
</ul>
<p>Now that I have the StartLSN and EndLSN I was ready to go.  Hit my breakpoint and the variables were set appropriately.  Woo-hoo!</p>
<p>Then…wait a minute…what?</p>
<pre class="brush: csharp;">vSQLQuery.Value =
    "SELECT " +
    "    c.__$operation " +
    "    , c.Column1 " +
    "    , c.Column2 " +
    "    , ColumnN " +
    "FROM " +
    "    cdc.fn_cdc_get_net_changes_&lt;instance_name&gt;( " + sStartLSN + ",  " + sEndLSN + ", 'all') c";</pre>
<p>That statement wasn’t changing the value of vSQLQuery.  huh?</p>
<p>Ok, I don’t by any stretch of the imagination claim to be an expert at C# but that looked pretty straight forward to me, however it wasn’t changing the value.</p>
<p>So now I start looking in earnest, <a href="http://www.google.com" target="_blank">google</a>, <a href="http://www.bing.com" target="_blank">bing</a>, <a href="http://stackoverflow.com/" target="_blank">Stackoverflow</a>, <a href="http://serverfault.com/" target="_blank">Serverfault</a>, all to no avail.  This just wasn’t making sense.  I was about to call over an expert C# person (<a href="http://www.magenic.com" target="_blank">Magenic</a> is full of them <img src='http://www.aaronlowe.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) when I remembered that my previous problem was not a problem with the code but a problem with the configuration of the task.  So I start looking into the configuration of the script task and the variables that I was using and that’s where I saw it. </p>
<p>vSQLValue was set to evaluate as an expression.  I had done this so I could copy and paste the SQL query I had developed in SSMS as opposed to making the query 1 line and pasting it into the value of the variable (the variable box in SSIS can’t interpret multi-line values, it only pastes the first line).</p>
<p>Turned off the fact that it was an expression and since it had already been evaluated it set the variable correctly (score!) and now I could manipulate the vSQLQuery.Value via the script task.</p>
<p>Now as to why I couldn’t modify a variable that is set to evaluate as an expression, I don’t know I’m sure there’s some sort of order of operations or locking catch here, but I still haven’t been able to find anything official about this.  Best I saw was <a href="http://weblogs.sqlteam.com/dmauri/archive/2006/04/02/9489.aspx" target="_blank">this</a> which would indicate to me that it would work.</p>
<p>Onto the next problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aaronlowe.net/archive/2009/12/ssis-cdc-lsn-debugging-nightmare-second-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSIS CDC LSN Debugging nightmare first problem</title>
		<link>http://www.aaronlowe.net/archive/2009/12/ssis-cdc-lsn-debugging-nightmare-first-problem/</link>
		<comments>http://www.aaronlowe.net/archive/2009/12/ssis-cdc-lsn-debugging-nightmare-first-problem/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 07:00:00 +0000</pubDate>
		<dc:creator>Aaron Lowe</dc:creator>
				<category><![CDATA[2008]]></category>
		<category><![CDATA[CDC]]></category>
		<category><![CDATA[SSIS]]></category>

		<guid isPermaLink="false">/post/2009/12/17/SSIS-CDC-LSN-Debugging-nightmare-first-problem.aspx</guid>
		<description><![CDATA[So now that we have the idea let’s look as the four main problems I encountered: The first problem I noticed was that the SQL query that was running still had nulls in on the StartLSN and EndLSN so I was querying: cdc.fn_cdc_get_net_changes_&#60;instance name&#62; (null, null, &#8216;all&#8217;) Which as I said last post, returns an [...]]]></description>
			<content:encoded><![CDATA[<p>So now that we have the idea let’s look as the four main problems I encountered:</p>
<p>The first problem I noticed was that the SQL query that was running still had nulls in on the StartLSN and EndLSN</p>
<p>so I was querying:</p>
<p>cdc.fn_cdc_get_net_changes_&lt;instance name&gt; (null, null, &#8216;all&#8217;)</p>
<p>Which as I said last post, returns an error. So throw a break point into the Script task and figure out why it’s not setting properly.&#160; This took me awhile, here’s the code:</p>
<pre class="brush: csharp;">var vStartLSN = Dts.Variables[&quot;User::sStartLSN&quot;];
var vEndLSN = Dts.Variables[&quot;User::sEndLSN&quot;];
var vSQLQuery = Dts.Variables[&quot;User::sSQLQuery&quot;];

string sStartLSN;
string sEndLSN;

Dts.VariableDispenser.LockForRead(&quot;User::sStartLSN&quot;);
Dts.VariableDispenser.LockForRead(&quot;User::sEndLSN&quot;);
Dts.VariableDispenser.LockForWrite(&quot;User::sSQLQuery&quot;);

sStartLSN = vStartLSN.Value.ToString();
sEndLSN = vEndLSN.Value.ToString();

vSQLQuery.Value =
    &quot;SELECT &quot; +
    &quot;    c.__$operation &quot; +
    &quot;    , c.Column1 &quot; +
    &quot;    , c.Column2 &quot; +
    &quot;    , ColumnN &quot; +
    &quot;FROM &quot; +
    &quot;    cdc.fn_cdc_get_net_changes_&lt;instance_name&gt;( &quot; + sStartLSN + &quot;,  &quot; + sEndLSN + &quot;, 'all') c&quot;;
Dts.Variables.Unlock();</pre>
<p>So hitting my first breakpoint, I first realized that the StartLSN variable was receiving a null.&#160; That wasn’t supposed to happen, so I looked at the SQL code I used to set the variables in the SQL Task:</p>
<p>SELECT sys.fn_cdc_get_min_lsn(&lt;instance_name&gt;) as @StartLSN</p>
<p>A-ha, that’s it. The function returns a record set and I had the task to just get a return value, not a record set.</p>
<p>So changed to:</p>
<p>SELECT @StartLSN = sys.fn_cdc_get_min_lsn(&lt;instance_name&gt;);<br />
  <br />SELECT @StartLSN as StartLSN</p>
<p>That got me past the first problem, now onto the next problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aaronlowe.net/archive/2009/12/ssis-cdc-lsn-debugging-nightmare-first-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSIS CDC LSN Debugging nightmare introduction</title>
		<link>http://www.aaronlowe.net/archive/2009/12/ssis-cdc-lsn-debugging-nightmare-introduction/</link>
		<comments>http://www.aaronlowe.net/archive/2009/12/ssis-cdc-lsn-debugging-nightmare-introduction/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 07:00:00 +0000</pubDate>
		<dc:creator>Aaron Lowe</dc:creator>
				<category><![CDATA[2008]]></category>
		<category><![CDATA[CDC]]></category>
		<category><![CDATA[SSIS]]></category>

		<guid isPermaLink="false">/post/2009/12/16/SSIS-CDC-LSN-Debugging-nightmare-introduction.aspx</guid>
		<description><![CDATA[The other day I was working on an SSIS implementation that was utilizing Change Data Capture (CDC) to identify the source data that needed to be transformed into the destination.&#160; This is the first time that I had used CDC other than a quick demo and I was grateful to have Whitney’s help with understanding [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I was working on an SSIS implementation that was utilizing <a href="http://msdn.microsoft.com/en-us/library/bb522489.aspx" target="_blank">Change Data Capture</a> (CDC) to identify the source data that needed to be transformed into the destination.&#160; This is the first time that I had used CDC other than a quick demo and I was grateful to have <a href="http://whitneyweaver.com/" target="_blank">Whitney’s</a> help with understanding some of the…shall we say eccentricities of CDC.</p>
<p>You can see <a href="http://www.codeplex.com/wikipage?ProjectName=MSFTISProdSamples&amp;title=SS2008!Change%20Data%20Capture%20since%20Last%20Request%20Package%20Sample" target="_blank">Change Data Capture since Last Request Package Sample</a> or <a href="http://www.codeplex.com/wikipage?ProjectName=MSFTISProdSamples&amp;title=SS2008!Change%20Data%20Capture%20for%20Specified%20Interval%20Package%20Sample" target="_blank">Change Data Capture for Specified Interval Package Sample</a> for the official MS examples which is the basis of what I was trying to accomplish, although in the specified interval sample they cheated by using a database snapshot to get the starting LSN and then just ran continuously from there keeping the LSNs in variables, they didn’t address the concept of true interval run that would be come to a stopping point and then start again after an interval passes.</p>
<p>So to give a little context to this post you need to understand some basics of SSIS and CDC.&#160; CDC utilizes <a href="http://msdn.microsoft.com/en-us/library/ms190411.aspx" target="_blank">Log Sequence Numbers</a> (LSNs) to know the start and stop point of the changes you are trying to identify.&#160; CDC is table based and logs those changes to an “instance” of the table that you specify, which is basically just a copy of the table DDL with a few added columns, the new table exists within the cdc schema and the table name is what you specify via the “instance name” parameter. You can track changes on the entire table or just specific columns, and there are functions to get all the changes or just the net changes.</p>
<p>Within CDC you have some very helpful system functions to assist with figuring out what LSNs you should be selecting, including:</p>
<ul>
<li>sys.fn_cdc_get_max_lsn      <br />sys.fn_cdc_get_min_lsn       <br />sys.fn_cdc_map_time_to_lsn       <br />sys.fn_cdc_map_lsn_to_time </li>
</ul>
<p>The other thing to remember is that LSNs are binary.&#160; In SSIS there is no variable type binary.&#160; The first odd thing I noticed (and this should have been a clue to the difficulties that lie ahead) was that the sys.fn_map_time_to_lsn has a strange parameter called the ‘relational operator’ and I kid you not these are the potential values:</p>
<ul>
<li>largest less than      <br />largest less than or equal       <br />smallest greater than       <br />smallest greater than or equal </li>
</ul>
<p>Yes the actual text strings are what is needed to be entered there.&#160; The idea being that LSNs aren’t directly time related to so you need to specify the relationship in relation to the datetime your passing.&#160; </p>
<p>The next&#160; thing I noticed that is strange was that sys.fn_cdc_get_min_lsn must be instance specific, while sys.fn_cdc_get_max_lsn is the entire server.&#160; So hopefully this will be a little more straight forward in the next version. &lt;TangentRant&gt;although that’s what I thought about Service Broker which I love, but sadly still isn’t that straight forward, however that’s for another post&lt;/TangentRant&gt;&#160; </p>
<p>So to cover all bases this was my process:</p>
<p>1.) The parent package would get the LSN boundaries based upon the last successful run of the package (StartLSN) and the current run (EndLSN), passing those variables to the children packages.</p>
<p>2.) The child package which is instance specific, would then verify that that StartLSN was not less than the minimum LSN for that instance, if it was, than use the MinLSN instead.&#160; </p>
<p>3.) Utilize the TVF to get the net changes cdc.fn_cdc_get_net_changes_&lt;capture_instance&gt; (to get all changes you would use cdc.fn_cdc_get_all_changes_&lt;capture_instance&gt;)    </p>
<p>A couple other issues here when using with SSIS here:</p>
<p>1.) It’s a TVF so if you pass bad parameters as start and end LSNs, you get an error in addition to the column header information:</p>
<p>“An insufficient number of arguments were supplied for the procedure or function cdc.fn_cdc_get_net_changes_ &#8230; .”</p>
<p>2.) It’s a TVF so you can’t use it as an OLEDB data source, instead you have to use an ssis variable as the data source, which mean the query needs to be set with the proper query with null values for the Start and End LSNs (remember even though it brings back an error it will bring back column information).&#160; This also means the script task is needed to change the alter the query string variable to substitute the proper start and end LSNs at runtime.</p>
<p>So now that we have the basis of what I was doing, now onto the debugging…</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aaronlowe.net/archive/2009/12/ssis-cdc-lsn-debugging-nightmare-introduction/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
