<?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>Lazycoder &#187; Database</title>
	<atom:link href="http://www.lazycoder.com/weblog/category/database/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lazycoder.com/weblog</link>
	<description></description>
	<lastBuildDate>Fri, 03 Feb 2012 23:26:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Mocking IDataReader using Rhino.Mocks 3.5</title>
		<link>http://www.lazycoder.com/weblog/2008/12/12/mocking-idatareader-using-rhinomocks-35/</link>
		<comments>http://www.lazycoder.com/weblog/2008/12/12/mocking-idatareader-using-rhinomocks-35/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 07:08:15 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/?p=1045</guid>
		<description><![CDATA[The other day I was writing unit tests for some legacy code and I needed to mock IDataReader. I really just wanted to populate the reader with a single row of data, then the Read() method should return false. Using Rhino.Mocks it was a piece of cake. PLAIN TEXT CODE: IDataReader reader = MockRepository.GenerateStub&#60;IDataReader&#62;&#40;&#41;; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I was writing unit tests for some legacy code and I needed to mock IDataReader. I really just wanted to populate the reader with a single row of data, then the Read() method should return false. Using Rhino.Mocks it was a piece of cake.</p>
<div class="igBar"><span id="lcode-3"><a href="#" onclick="javascript:showCodeTxt('code-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-3">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">IDataReader reader = MockRepository.<span style="">GenerateStub</span>&lt;IDataReader&gt;<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reader.<span style="">Stub</span><span style="color:#006600; font-weight:bold;">&#40;</span>x =&gt; x.<span style="">Read</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">Return</span><span style="color:#006600; font-weight:bold;">&#40;</span>true<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">Repeat</span>.<span style="">Times</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reader.<span style="">Stub</span><span style="color:#006600; font-weight:bold;">&#40;</span>x =&gt; x.<span style="">Read</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">Return</span><span style="color:#006600; font-weight:bold;">&#40;</span>false<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reader.<span style="">Stub</span><span style="color:#006600; font-weight:bold;">&#40;</span>x =&gt; x<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC0000;">"ID"</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">Return</span><span style="color:#006600; font-weight:bold;">&#40;</span>Guid.<span style="">Empty</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reader.<span style="">Stub</span><span style="color:#006600; font-weight:bold;">&#40;</span>x =&gt; x<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC0000;">"FullName"</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">Return</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"Test User"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List&lt;UserDTO&gt; list = SearchProvider.<span style="">ParseUserData</span><span style="color:#006600; font-weight:bold;">&#40;</span>reader<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Assert.<span style="">IsNotNull</span><span style="color:#006600; font-weight:bold;">&#40;</span>list<span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The magic happens in the Repeat.Times(1) statement. This tells Rhino.Mocks that when the method is called, the mock should Return the given value that number of times. After that it can return a different value.</p>
<p>Update: <a href="http://codebetter.com/blogs/jeremy.miller/default.aspx">Jeremy Miller</a> told me about the DataTableReader class in the BCL and that you can use it to stub out IDataReader. I like this better because it removes the dependency the test had on Rhino.Mocks.</p>
<div class="igBar"><span id="lcode-4"><a href="#" onclick="javascript:showCodeTxt('code-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-4">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">DataTable table = new DataTable<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DataRow row = table.<span style="">NewRow</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; table.<span style="">Columns</span>.<span style="">Add</span><span style="color:#006600; font-weight:bold;">&#40;</span>new DataColumn<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"ID"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; table.<span style="">Columns</span>.<span style="">Add</span><span style="color:#006600; font-weight:bold;">&#40;</span>new DataColumn<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"FullName"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; row<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC0000;">"DirectoryUserID"</span><span style="color:#006600; font-weight:bold;">&#93;</span> = Guid.<span style="">Empty</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; row<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC0000;">"FullName"</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#CC0000;">"Test User"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; table.<span style="">Rows</span>.<span style="">Add</span><span style="color:#006600; font-weight:bold;">&#40;</span>row<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DataTableReader reader = new DataTableReader<span style="color:#006600; font-weight:bold;">&#40;</span>table<span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2008/12/12/mocking-idatareader-using-rhinomocks-35/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Dealing with comma delimited data in a database column</title>
		<link>http://www.lazycoder.com/weblog/2008/05/13/dealing-with-comma-delimited-data-in-a-database-column/</link>
		<comments>http://www.lazycoder.com/weblog/2008/05/13/dealing-with-comma-delimited-data-in-a-database-column/#comments</comments>
		<pubDate>Tue, 13 May 2008 23:27:34 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/?p=941</guid>
		<description><![CDATA[For various reasons, developers through the years have decided to store lists of data as comma-separated lists. Most programming languages include a split() function that allows you to break apart a list of data using a specified character. T-SQL does not. I don't remember where I got this split function from. I know I didn't [...]]]></description>
			<content:encoded><![CDATA[<p>For various reasons, developers through the years have decided to store lists of data as comma-separated lists. Most programming languages include a split() function that allows you to break apart a list of data using a specified character.  T-<acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> does not.</p>
<p>I don't remember where I got this split function from. I know I didn't write all of it from scratch. But basically what it will do is take a delimited list of data, split it apart, and return a table where each data element is associated with the identity value you pass into the function. This is very useful if you just want to get the values for a single row.</p>
<div class="igBar"><span id="lcode-7"><a href="#" onclick="javascript:showCodeTxt('code-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-7">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">CREATE&nbsp; function Split</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @list varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">8000</span><span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @identityVal int,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @SplitChar char<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">RETURNS @RetVal table</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; id int,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Value nvarchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">1000</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">AS</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">BEGIN</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; WHILE <span style="color:#006600; font-weight:bold;">&#40;</span>Charindex<span style="color:#006600; font-weight:bold;">&#40;</span>@SplitChar,@list<span style="color:#006600; font-weight:bold;">&#41;</span>&gt;<span style="color:#800000;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; BEGIN</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Insert Into @RetVal <span style="color:#006600; font-weight:bold;">&#40;</span>id,Value<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Select @identityVal,value = <span style="color:#006600; font-weight:bold;">&#40;</span>ltrim<span style="color:#006600; font-weight:bold;">&#40;</span>rtrim<span style="color:#006600; font-weight:bold;">&#40;</span>Substring<span style="color:#006600; font-weight:bold;">&#40;</span>@list,<span style="color:#800000;color:#800000;">1</span>,charindex<span style="color:#006600; font-weight:bold;">&#40;</span>@SplitChar,@list<span style="color:#006600; font-weight:bold;">&#41;</span>-<span style="color:#800000;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; SET @list = Substring<span style="color:#006600; font-weight:bold;">&#40;</span>@List,Charindex<span style="color:#006600; font-weight:bold;">&#40;</span>@SplitChar,@list<span style="color:#006600; font-weight:bold;">&#41;</span>+len<span style="color:#006600; font-weight:bold;">&#40;</span>@SplitChar<span style="color:#006600; font-weight:bold;">&#41;</span>,len<span style="color:#006600; font-weight:bold;">&#40;</span>@list<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; END</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; INSERT INTO @RetVal <span style="color:#006600; font-weight:bold;">&#40;</span>id,Value<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; SELECT @identityVal, ltrim<span style="color:#006600; font-weight:bold;">&#40;</span>rtrim<span style="color:#006600; font-weight:bold;">&#40;</span>@list<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; RETURN</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">END </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>So what happens if you are trying to build a view or a report and need to split apart multiple rows. You can iterate over the rows in the table you want to flatten out and call the split function for each row, passing the rows PK into the split function.</p>
<div class="igBar"><span id="lcode-8"><a href="#" onclick="javascript:showCodeTxt('code-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-8">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">create function fnFlattenMyTable</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">RETURNS @RetVal table </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; PrimaryKeyId int, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; MyListValue varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">100</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">AS</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">BEGIN</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Declare @PrimaryKeyId int</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Declare @MyListColumn varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">6000</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">SET @PrimaryKeyId = <span style="color:#006600; font-weight:bold;">&#40;</span>select MIN<span style="color:#006600; font-weight:bold;">&#40;</span>PrimaryKeyId <span style="color:#006600; font-weight:bold;">&#41;</span> FROM MyTable<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">WHILE @PrimaryKeyId&nbsp; is not null --main loop through MyTable</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">BEGIN</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Set @MyListColumn = <span style="color:#006600; font-weight:bold;">&#40;</span>select MyListColumn from MyTable where PrimaryKeyId&nbsp; = @PrimaryKeyId <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; insert into @RetVal<span style="color:#006600; font-weight:bold;">&#40;</span>PrimaryKeyId , MyListValue <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; select id, value from <span style="color:#006600; font-weight:bold;">&#91;</span>Split<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#40;</span>@MyListColumn , @PrimaryKeyId , <span style="color:#CC0000;">','</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; SET @PrimaryKeyId&nbsp; = <span style="color:#006600; font-weight:bold;">&#40;</span>select MIN<span style="color:#006600; font-weight:bold;">&#40;</span>PrimaryKeyId <span style="color:#006600; font-weight:bold;">&#41;</span> FROM MyTable where PrimaryKeyId &gt; @PrimaryKeyId <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">END</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">RETURN</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">END </div>
</li>
</ol>
</div>
</div>
</div>
<p>
This function uses one of my favorite sql tricks. It uses a while loop to avoid having to declare a cursor . The logic is pretty simple, on each loop, select the lowest value of the PK in the table that is higher than the previous PK. That's the roundabout way of saying, "Select the next highest PK from the table".</p>
<p>Right now, this function is hard coded to flatten the table "MyTable", but it could be re-factored into a general use function.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2008/05/13/dealing-with-comma-delimited-data-in-a-database-column/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Re-associate SQL users with logins</title>
		<link>http://www.lazycoder.com/weblog/2007/06/04/re-associate-sql-users-with-logins/</link>
		<comments>http://www.lazycoder.com/weblog/2007/06/04/re-associate-sql-users-with-logins/#comments</comments>
		<pubDate>Mon, 04 Jun 2007 22:49:12 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/index.php/archives/2007/06/04/re-associate-sql-users-with-logins/</guid>
		<description><![CDATA[I've been getting our test environment in sync with our production environment the past week. Part of this effort involves moving database from our production environment to our test database server. The easiest way to do this is to put the production server into single-user mode, copy the .MDF and .LDF database files over to [...]]]></description>
			<content:encoded><![CDATA[<p>I've been getting our test environment in sync with our production environment the past week. Part of this effort involves moving database from our production environment to our test database server. The easiest way to do this is to put the production server into single-user mode, copy the .MDF and .LDF database files over to the test database server, and the attach the database files to the test database server.</p>
<p>The unfortunate side effect of this is that the <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> users in each database are no long associated with the <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Login. <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server has had an sp called '<a href="http://msdn2.microsoft.com/en-us/library/aa259633(<acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym>.80).aspx">sp_change_users_login</a>' since <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server 2000. You can pass in the 'Auto_Fix' parameter and the name of the <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> user that is orphaned and <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server will do it's best to automatically match the user name up with a <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> login. There are a few gotchas that the <acronym title='Microsoft Developer Network'><span class='caps'>MSDN</span></acronym> article, and people better versed in <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server internals than I, can spell out. But for 90% of the cases out there, this SP will work fine. But it only works on one user at a time. So I created the world simplest code generator to help me create all of the statements needed to attempt to reassociate my users with their logins.</p>
<div class="igBar"><span id="lsql-10"><a href="#" onclick="javascript:showCodeTxt('sql-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName"><acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym>:</span>
<div id="sql-10">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #ff0000;">'exec sp_change_users_login '</span><span style="color: #ff0000;">'Auto_Fix'</span><span style="color: #ff0000;">','</span><span style="color: #ff0000;">''</span> + name + <span style="color: #ff0000;">''</span><span style="color: #ff0000;">''</span> <span style="color: #993333; font-weight: bold;">FROM</span> sysusers <span style="color: #993333; font-weight: bold;">WHERE</span> uid&gt; <span style="color: #cc66cc;color:#800000;">2</span> <span style="color: #993333; font-weight: bold;">AND</span> uid &lt;<span style="color: #cc66cc;color:#800000;">16000</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>uid 2 is the guest account and uids > 16000 are the built in "db_*" users.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2007/06/04/re-associate-sql-users-with-logins/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Language performance doesn&#8217;t matter when a database is involved</title>
		<link>http://www.lazycoder.com/weblog/2007/04/17/language-performance-doesnt-matter-when-a-database-is-involved/</link>
		<comments>http://www.lazycoder.com/weblog/2007/04/17/language-performance-doesnt-matter-when-a-database-is-involved/#comments</comments>
		<pubDate>Tue, 17 Apr 2007 15:39:14 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/index.php/archives/2007/04/17/language-performance-doesnt-matter-when-a-database-is-involved/</guid>
		<description><![CDATA[All of the latest Rails/Twitter performance bruhaha made me think about some advice I got a long time ago and that I dish out whenever someone asks me about some performance concerns they have with their code. Nothing else matters once you hit the disk. Once you do any kind of activity that involves reading/writing [...]]]></description>
			<content:encoded><![CDATA[<p>All of the latest <a href="http://www.loudthinking.com/arc/000608.html">Rails/Twitter performance bruhaha</a> made me think about some advice I got a long time ago and that I dish out whenever someone asks me about some <a href="http://www.lazycoder.com/weblog/index.php/archives/2005/04/05/performance-costs-of-reflection/">performance concerns</a> they have with their code.</p>
<p>Nothing else matters once you hit the disk. Once you do any kind of activity that involves reading/writing to a hard disk, that activity instantly becomes your greatest performance drag. No matter how slow any language is at interpreting/JITing/compiling, it's still orders of magnitude faster than interacting with a hard disk with physical, moving parts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2007/04/17/language-performance-doesnt-matter-when-a-database-is-involved/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Bad things to hear from your DBA</title>
		<link>http://www.lazycoder.com/weblog/2005/07/06/bad-things-to-hear-from-your-dba/</link>
		<comments>http://www.lazycoder.com/weblog/2005/07/06/bad-things-to-hear-from-your-dba/#comments</comments>
		<pubDate>Wed, 06 Jul 2005 21:03:22 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/?p=458</guid>
		<description><![CDATA[It's not good to hear your DBA 'guru' answer "Good question" when he's been working for 2 months creating insert and update DTS packages for your application and you ask him "How can you tell if you are supposed to insert or update a given record in the source table?". Especially when NOT being able [...]]]></description>
			<content:encoded><![CDATA[<p>It's not good to hear your DBA 'guru' answer "Good question" when he's been working for 2 months creating insert and  update DTS packages for your application and you ask him "How can you tell if you are supposed to insert or update a given record in the source table?".</p>
<p>Especially when NOT being able to tell the difference would result in over 500K duplicate inserts every day. (especially when the reason you've asked him that question is because you noticed his DTS package would result in the 500K dupe inserts/day).</p>
<p>grrrrrrrrrr</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2005/07/06/bad-things-to-hear-from-your-dba/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Size of scientific datasets</title>
		<link>http://www.lazycoder.com/weblog/2005/04/28/size-of-scientific-datasets-2/</link>
		<comments>http://www.lazycoder.com/weblog/2005/04/28/size-of-scientific-datasets-2/#comments</comments>
		<pubDate>Thu, 28 Apr 2005 17:31:57 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/archives/2005/04/28/size-of-scientific-datasets-2/</guid>
		<description><![CDATA[I deal mostly with medical data, some appointment data, but mostly data about a patients labs, medications, and what they are having taken out or put into them. These databases can get pretty big, right now I've got three main databases. One is about 1.5GB, the second is abou 2.3GB, and the third, which is [...]]]></description>
			<content:encoded><![CDATA[<p>I deal mostly with medical data, some appointment data, but mostly data about a patients labs, medications, and what they are having taken out or put into them.  These databases can get pretty big, right now I've got three main databases. One is about 1.5GB, the second is abou 2.3GB, and the third, which is a staging database for the other two, is about 4GB. These aren't very big compared to the multi-<a href="http://en.wikipedia.org/wiki/Terabyte">terrabyte</a> (10^12 or 2^40 bytes)  databases you'll see at Fortune 500 companies or at Google.</p>
<p>But then you start to look at the data sets that <a href="http://en.wikipedia.org/wiki/Supercollider">supercolliders</a> turn out. These supercolliders can churn out 10 <a href="http://en.wikipedia.org/wiki/Petabyte">petabyte</a> (10^15 or 2^50 bytes)  datasets each time they run.  Some astronomical data sets run into the 10PB/year range. None of these are in a RDBMS yet. None can handle that much data all at once yet.  Datasets in this range fascinate me because I can't really visualize a multi-<acronym title='Terabyte'><span class='caps'>TB</span></acronym> dataset, let alone a single petabyte. I know that some of the researchers here have multiple 100+<acronym title='Gigabyte'><span class='caps'>GB</span></acronym> Firewire external hard drives chained together holding DNA and  protein sequence information. Usually in hundreds and thousands of Excel spreadsheets(groan).</p>
<p>Check out this <a href="http://research.microsoft.com/~Gray/talks/In%20Search%20of%20PetaByte%20Databases.ppt">PowerPoint by Jim Gray of MS Research</a> where he talks about some of the larger datasets. Interesting that Google was a 1.5PB as of spring 2001. WAY before the GMail initiative or Google Video upload. I wonder where they are now?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2005/04/28/size-of-scientific-datasets-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Oracle just ain&#8217;t no damn good</title>
		<link>http://www.lazycoder.com/weblog/2005/02/21/oracle-just-aint-no-damn-good/</link>
		<comments>http://www.lazycoder.com/weblog/2005/02/21/oracle-just-aint-no-damn-good/#comments</comments>
		<pubDate>Mon, 21 Feb 2005 18:02:17 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/archives/2005/02/21/oracle-just-aint-no-damn-good/</guid>
		<description><![CDATA[There's No Place Like 131.107.2.200: Oracle keeps on sucking Matthew is having some problems with Oracle. I don't know why he would inflict that kind of pain upon himself, but my guess is it's client driven. Damn clients. I briefly had to work with Oracle 8i at a previous job. I couldn't figure out any [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://spaces.msn.com/members/mroche/Blog/cns!1pbZR_negsuAMGl6R9biRT0Q!413.entry">There's No Place Like 131.107.2.200: Oracle keeps on sucking</a></p>
<p>Matthew is having some problems with Oracle. I don't know why he would inflict that kind of pain upon himself, but my guess is it's client driven. Damn clients.</p>
<p>I briefly had to work with Oracle 8i at a previous job. I couldn't figure out any of their gui tools, half of them wouldn't install correctly and I think it took about 2 hours to get to the point where I realized I couldn't install them. (This was back in the Win2K days, not the halcyon days of hmmmm, damn guess I'm still using Win2K. In any case RAM was more expensive so we didn't have a lot.) I ended up just writing all my DB creation scripts in ViM and running them in <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym>+(I think that's right).</p>
<p>Then they laid off the DBA, who promptly too the admin password with him off to Vegas (Las Vegas, NM). Of course when we called him up and asked him for the password he couldn't remember it. Thus began our forced migration to <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server. I couldn't log into any admin interface in Oracle, but we did have a user account that had read access to all of the databases. Yay! So I ended up linking them Oracle server to my <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server and using DTS to migrate the data over.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2005/02/21/oracle-just-aint-no-damn-good/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SQL Injection via SQL Parameters?</title>
		<link>http://www.lazycoder.com/weblog/2004/09/21/sql-injection-via-sql-parameters/</link>
		<comments>http://www.lazycoder.com/weblog/2004/09/21/sql-injection-via-sql-parameters/#comments</comments>
		<pubDate>Tue, 21 Sep 2004 18:12:51 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/archives/2004/09/21/sql-injection-via-sql-parameters/</guid>
		<description><![CDATA[Possible SQL Injection via SQL Parameters? Pick up "Writing Secure Code v.2", They discuss how a SQL parameter can be used as an injection attack. Mostly, the examples I've seen center around the "exec" statement, either embedded in the code or in an SProc. sqlString = "exec sp_DoSomeStuff '" + inputFromUser + "'"; SqlCommand cmd [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://dotnetjunkies.com/WebLog/BsBlog/archive/2004/09/21/26339.aspx">Possible <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Injection via <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Parameters?</a></p>
<p>Pick up "Writing Secure Code v.2", They discuss how a <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> parameter can be used as an injection attack. </p>
<p>Mostly, the examples I've seen center around the "exec" statement, either embedded in the code or in an SProc.</p>
<pre><code>
sqlString = "exec sp_DoSomeStuff '" + inputFromUser + "'";
SqlCommand cmd = new SqlCommand(conn,sqlString)</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2004/09/21/sql-injection-via-sql-parameters/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Wesley might have made a few mistakes&#8230;</title>
		<link>http://www.lazycoder.com/weblog/2004/07/11/wesley-might-have-made-a-few-mistakes/</link>
		<comments>http://www.lazycoder.com/weblog/2004/07/11/wesley-might-have-made-a-few-mistakes/#comments</comments>
		<pubDate>Sun, 11 Jul 2004 21:20:14 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/archives/2004/07/11/wesley-might-have-made-a-few-mistakes/</guid>
		<description><![CDATA[The Code Project - C# Performance: Mistakes My Friend Makes - C# Programming But Ellery makes a couple of his own. Prefixing your variables with the type (i.e. sName), is not very .NET. Reason for this being that your variables are suppose to have meaningful names which allow their type to be identify without the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.codeproject.com/purgatory/C__Performance.asp">The Code Project - C# Performance: Mistakes My Friend Makes - C# Programming</a></p>
<p>But Ellery makes a couple of his own.</p>
<blockquote><p>
Prefixing your variables with the type (i.e. sName), is not very .NET. Reason for this being that your variables are suppose to have meaningful names which allow their type to be identify without the need for a prefix. Itís pretty easy to see the variable types of firstName and dateOfBirth. I believe most people who do this are/were VB programmers who canít get rid of the habit.
</p></blockquote>
<p>So what's the type of dateOfBirth? Does it return a string? Is the date it returns a DateTime short date string or long date string? Does it return a DateTime type? Do you have to hover over the var name to find out? How much time does that take our of your day, trying to find the right hover spot in Visual Studio?</p>
<blockquote><p>
In Wesleyís code, the SqlParameter does nothing but introduce unnecessary overhead and code complexity. You can provide parameters to a stored procedure by simply executing it in the <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> code (i.e. ìEXEC usp_GetUserDataByID 257;î).
</p></blockquote>
<p>Yes, that's a great idea provided that Wesley doesn't care about <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> injection attacks? Concatinating together an "EXEC" statement to execute a stored procedure is almost as bad as concatinating the <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> string together.</p>
<blockquote><p>
Although not seen in this code example, he ALWAYS sets the CommandType property of the SqlCommand objects, even when he needs CommandType.Text. Text is the default value for that field. No need to set it.
</p></blockquote>
<p>You should never rely on the default properties of classes and methods. What happens to your code if the default property or the underlying enum is changed? Ellery has some learning to do to.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2004/07/11/wesley-might-have-made-a-few-mistakes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ObjectSpaces and WinFS and vendor lockin</title>
		<link>http://www.lazycoder.com/weblog/2004/06/14/objectspaces-and-winfs-and-vendor-lockin/</link>
		<comments>http://www.lazycoder.com/weblog/2004/06/14/objectspaces-and-winfs-and-vendor-lockin/#comments</comments>
		<pubDate>Mon, 14 Jun 2004 21:25:33 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/archives/2004/06/14/objectspaces-and-winfs-and-vendor-lockin/</guid>
		<description><![CDATA[ObjectSpaces and WinFS Part 2 - Apples and Apples Hank Fay hits upon a key piece of information that no one is mentioning in all the press/blog entries surround the rolling of Object Spaces into WinFS. Question: will this merger create unbreakable tie-in between ObjectSpaces and WinFS, such that other relational datastores (think Oracle, MySQL, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blogs.msdn.com/aconrad/archive/2004/06/14/155279.aspx">ObjectSpaces and WinFS Part 2 - Apples and Apples</a></p>
<p><a href="http://www.prosysplus.com/">Hank Fay</a> hits upon a key piece of information that no one is mentioning in all the press/blog entries surround the rolling of Object Spaces into WinFS.</p>
<blockquote><p>Question: will this merger create unbreakable tie-in between ObjectSpaces and WinFS, such that other relational datastores (think Oracle, MySQL, PostGreSQL, DB2, Firebird, etc.) are no longer in the picure? Or am I missing something here?</p></blockquote>
<p>Nope Hank, I'd say you are right on target. Unless MS plans to make the ObjectSpaces provider pluggable (e.g. a FileSystem provider, a Sql Provider, a Exchange Mailbox provider, etc...) I'd say that's exactly what Microsoft is hoping for. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2004/06/14/objectspaces-and-winfs-and-vendor-lockin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

