<?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>Eatdoku Blog</title>
	<atom:link href="http://blog.eatdoku.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.eatdoku.com</link>
	<description>My blog on everything~</description>
	<lastBuildDate>Sat, 19 Sep 2009 05:56:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Picture posting</title>
		<link>http://blog.eatdoku.com/?p=57</link>
		<comments>http://blog.eatdoku.com/?p=57#comments</comments>
		<pubDate>Sat, 19 Sep 2009 05:56:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Test]]></category>

		<guid isPermaLink="false">http://blog.eatdoku.com/?p=57</guid>
		<description><![CDATA[Featured Themes Skinbu DownloadClever Theme, fixed-width, widget ready, two colums, right sidebar support hierarchical categories, valid html and CSS and compatible with WordPress 2.8 and higher. LightWord DownloadSimply clever theme with two columns, right-sidebar, fixed-width, widget-ready and threaded comments. Compatible with WordPress 2.8, valid XHTML &#38; CSS. Stay updated!]]></description>
			<content:encoded><![CDATA[<p><span style="font-family: 'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial, sans-serif; line-height: 22px; font-size: 12px; color: #555555" class="Apple-style-span"><br />
<h3 style="margin-top: -1px; margin-right: 0px; margin-bottom: 18px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: bold; font-size: 14px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dedede" class="head">Featured Themes</h3>
<p style="clear: both; margin-top: 0px; margin-right: 0px; margin-bottom: 2em; margin-left: 0px; padding: 0px" class="block-content"><a href="http://wordpress.org/extend/themes/skinbu" style="text-decoration: none; color: #21759b; font-weight: normal"><img src="http://wp-themes.com/wp-content/themes/skinbu/screenshot.png" style="border-style: solid; border-color: #cccccc; margin-right: 10px; margin-bottom: 10px; width: 160px; height: 120px; border-width: 1px; padding: 3px" align="left" /></a><br />
<h4 style="padding-top: 1px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-style: normal; font-weight: bold; font-size: 14px; color: #333333; border-width: initial !important; border-color: initial !important; border-style: none !important; margin: 0px"><a href="http://wordpress.org/extend/themes/skinbu" style="text-decoration: none; color: #21759b; font-weight: normal">Skinbu</a></h4>
<p><span style="font: normal normal normal 11px/16px 'Lucida Grande', Verdana, Arial, 'Bitstream Vera Sans', sans-serif; text-decoration: none; cursor: pointer; border-top-left-radius: 11px 11px; border-top-right-radius: 11px 11px; border-bottom-right-radius: 11px 11px; border-bottom-left-radius: 11px 11px; -webkit-box-sizing: content-box; color: #464646; text-shadow: #ffffff 0px 1px 0px; background-image: url('http://s.wordpress.org/style/images/white-grad.png'); background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: #f2f2f2; font-weight: normal !important; float: right; line-height: 10px; font-size: 10px; margin-left: 14px; background-position: 0% 0%; background-repeat: repeat no-repeat; border-width: 1px; border-color: #bbbbbb; border-style: solid; padding: 3px" class="download button"><a href="http://wordpress.org/extend/themes/download/skinbu.1.0.3.zip" style="text-decoration: none; color: #21759b; font-weight: normal !important; border-width: initial !important; border-color: initial !important; border-style: none !important">Download</a></span>Clever Theme, fixed-width, widget ready, two colums, right sidebar support hierarchical categories, valid html and CSS and compatible with WordPress 2.8 and higher.
<p style="clear: both; margin-top: 0px; margin-right: 0px; margin-bottom: 2em; margin-left: 0px; padding: 0px" class="block-content"><a href="http://wordpress.org/extend/themes/lightword" style="text-decoration: none; color: #4ca6cf; font-weight: normal"><img src="http://wp-themes.com/wp-content/themes/lightword/screenshot.png" style="border-style: solid; border-color: #cccccc; margin-right: 10px; margin-bottom: 10px; width: 160px; height: 120px; border-width: 1px; padding: 3px" align="left" /></a><br />
<h4 style="padding-top: 1px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-style: normal; font-weight: bold; font-size: 14px; color: #333333; border-width: initial !important; border-color: initial !important; border-style: none !important; margin: 0px"><a href="http://wordpress.org/extend/themes/lightword" style="text-decoration: none; color: #4ca6cf; font-weight: normal">LightWord</a></h4>
<p><span style="font: normal normal normal 11px/16px 'Lucida Grande', Verdana, Arial, 'Bitstream Vera Sans', sans-serif; text-decoration: none; cursor: pointer; border-top-left-radius: 11px 11px; border-top-right-radius: 11px 11px; border-bottom-right-radius: 11px 11px; border-bottom-left-radius: 11px 11px; -webkit-box-sizing: content-box; color: #464646; text-shadow: #ffffff 0px 1px 0px; background-image: url('http://s.wordpress.org/style/images/white-grad.png'); background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: #f2f2f2; font-weight: normal !important; float: right; line-height: 10px; font-size: 10px; margin-left: 14px; background-position: 0% 0%; background-repeat: repeat no-repeat; border-width: 1px; border-color: #bbbbbb; border-style: solid; padding: 3px" class="download button"><a href="http://wordpress.org/extend/themes/download/lightword.1.9.1.zip" style="text-decoration: none; color: #21759b; font-weight: normal !important; border-width: initial !important; border-color: initial !important; border-style: none !important">Download</a></span>Simply clever theme with two columns, right-sidebar, fixed-width, widget-ready and threaded comments. Compatible with WordPress 2.8, valid XHTML &amp; CSS. Stay updated!</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eatdoku.com/?feed=rss2&amp;p=57</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Code quality!!</title>
		<link>http://blog.eatdoku.com/?p=55</link>
		<comments>http://blog.eatdoku.com/?p=55#comments</comments>
		<pubDate>Mon, 29 Jun 2009 15:31:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Quality]]></category>

		<guid isPermaLink="false">http://blog.eatdoku.com/?p=55</guid>
		<description><![CDATA[Some good articles are how to improve code quality and why you need them!!Code Quality for teamsCode Quality – Learn: OOPs, Desing Patterns, Clean Code and Refactoring7 tips on writing clean codeWriting clean code ]]></description>
			<content:encoded><![CDATA[<p>Some good articles are how to improve code quality and why you need them!!<a href="http://www.infoq.com/news/2009/06/code-quality-for-teams">Code Quality for teams</a><a href="http://www.infoq.com/news/2009/06/code-quality-for-teams"></a><a href="http://jaibeermalik.wordpress.com/2009/04/12/code-quality-learn-oops-desing-patterns-clean-code-and-refactoring/">Code Quality – Learn: OOPs, Desing Patterns, Clean Code and Refactoring</a><a href="http://jaibeermalik.wordpress.com/2009/04/12/code-quality-learn-oops-desing-patterns-clean-code-and-refactoring/"></a><a href="http://www.garshol.priv.no/blog/105.html">7 tips on writing clean code</a><a href="http://www.garshol.priv.no/blog/105.html"></a><a href="http://www.ibm.com/developerworks/rational/library/nov06/pollice/index.html">Writing clean code </a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eatdoku.com/?feed=rss2&amp;p=55</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Restore SQL Server database from multiple backup files vis script</title>
		<link>http://blog.eatdoku.com/?p=54</link>
		<comments>http://blog.eatdoku.com/?p=54#comments</comments>
		<pubDate>Fri, 16 Jan 2009 23:11:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[TSQL]]></category>

		<guid isPermaLink="false">http://blog.eatdoku.com/?p=54</guid>
		<description><![CDATA[RESTORE DATABASE OMNIHDMDR FROMDISK = &#8216;C:\FILE1.bak&#8217;,DISK = &#8216;C:\FILE2.bak&#8217;,DISK = &#8216;C:\FILE3.bak&#8217;,DISK = &#8216;C:\FILE4.bak&#8217;,DISK = &#8216;C:\FILE5.bak&#8217;,WITHMOVE &#8216;XXX_Data&#8217; TO &#8216;C:\SQLData\Data\XXX_Data.mdf&#8217;,MOVE &#8216;XXX_log&#8217; TO &#8216;C:\SQLData\Log\XXX_Log.ldf&#8217;,MOVE &#8216;XXX_XXXKeywordCatalog&#8217; TO &#8216;C:\SQLData\FullText\XXX&#8217;,RECOVERY]]></description>
			<content:encoded><![CDATA[<p>RESTORE DATABASE OMNIHDMDR FROMDISK = &#8216;C:\FILE1.bak&#8217;,DISK = &#8216;C:\FILE2.bak&#8217;,DISK = &#8216;C:\FILE3.bak&#8217;,DISK = &#8216;C:\FILE4.bak&#8217;,DISK = &#8216;C:\FILE5.bak&#8217;,WITHMOVE &#8216;XXX_Data&#8217; TO &#8216;C:\SQLData\Data\XXX_Data.mdf&#8217;,MOVE &#8216;XXX_log&#8217; TO &#8216;C:\SQLData\Log\XXX_Log.ldf&#8217;,MOVE &#8216;XXX_XXXKeywordCatalog&#8217; TO &#8216;C:\SQLData\FullText\XXX&#8217;,RECOVERY</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eatdoku.com/?feed=rss2&amp;p=54</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>see a list of the used ports on your computer</title>
		<link>http://blog.eatdoku.com/?p=53</link>
		<comments>http://blog.eatdoku.com/?p=53#comments</comments>
		<pubDate>Wed, 22 Oct 2008 20:05:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CMD]]></category>

		<guid isPermaLink="false">http://blog.eatdoku.com/?p=53</guid>
		<description><![CDATA[cmd netstat -a]]></description>
			<content:encoded><![CDATA[<p>cmd</p>
<p>netstat -a</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eatdoku.com/?feed=rss2&amp;p=53</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ORA-01555: snapshot too old error in Oracle</title>
		<link>http://blog.eatdoku.com/?p=52</link>
		<comments>http://blog.eatdoku.com/?p=52#comments</comments>
		<pubDate>Thu, 31 Jul 2008 19:33:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[PLSQL]]></category>
		<category><![CDATA[Snapshot too old]]></category>

		<guid isPermaLink="false">http://blog.eatdoku.com/?p=52</guid>
		<description><![CDATA[When an update starts, Oracle &#8216;queries&#8217; what data it will update. This is the starting point and needs to be consistent untill the update has finished. This is often referred to as read consistent view of the data. Now, what is the use of that? Say, for example, that another user would start inserting data [...]]]></description>
			<content:encoded><![CDATA[<p>When an update starts, Oracle &#8216;queries&#8217; what data it will update. This is the starting point and needs to be consistent untill the update has finished. This is often referred to as read consistent view of the data.   <br />Now, what is the use of that?    <br />Say, for example, that another user would start inserting data while you&#8217;re still busy updating, then this user wouldn&#8217;t be happy to find that his new inserted data would be included in the update statement.    <br />So, Oracle needs to keep track of the original state of the data as it was when the update started. </p>
<p>Now, how does commiting affect this read consistency?   <br />While updating, undo information is saved. After a commit, this undo information is no longer protected.    <br />This doesn&#8217;t have to be a problem, becaust Oracle can still access the information in the undo segment to create a read consistent view of the data.    <br />But, the moment a another transaction reuses this undo space, the undo is overwritten by other undo and there is no longer read consistency: you&#8217;ll get the &#8216;ORA-01555: snapshot too old&#8217; error.</p>
<p>Be aware that it doesn&#8217;t need to be another user to reuse undo: it might be yourself updating the next set.   <br />Large and many undo segments will make it less likely to hit that error, but are no garantee.    <br />You can have lots of undo space, but still run into this error, because after a commit a rollback segment will not grow but reuse the freed up space.    <br />If your next transaction happens to use the same rollback segment, you&#8217;re hit the ORA-01555</p>
<p>To do it in one large update, how big should your rollback segment be?   <br />That is hard to predict how much you need, I would suggest to just go for it.    <br />If it fails, no damage is done. You can enlarge your undo tablespace and/or rollback segment and retry it.    <br />If it doesn&#8217;t, fail, you&#8217;re home free.</p>
<p>I tried this update in my own test environment:   <br />update dps_user set password = lower(password);    <br />It took about 5 minutes, updated 3.7 million records and used 560 MB (70K undo blocks * 8K (db_block_size)).</p>
<p>I&#8217;m happy enough with that.</p>
<p>Cheers, </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eatdoku.com/?feed=rss2&amp;p=52</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test Posts</title>
		<link>http://blog.eatdoku.com/?p=51</link>
		<comments>http://blog.eatdoku.com/?p=51#comments</comments>
		<pubDate>Sun, 27 Jul 2008 00:46:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.eatdoku.com/?p=51</guid>
		<description><![CDATA[物件名稱: 忠泰交響曲 地址: 中山區大直豪宅 總價: 12800萬    (含車位) 登記面積: 103.08坪    (車位坪數另計) 公設面積: 28.84坪 車位: 3個   (坡道/平面) 屋齡: 0年 隔局: 4 /2 /4衛 座向: 朝南 特色:1.水岸第一排，稀有頂樓景觀 2.坐擁180度水岸，日夜美景 3.忠泰制震豪宅，1500坪基地磅薄 4.繼輕井澤、代官山、未來大直新指標]]></description>
			<content:encoded><![CDATA[<p><strong>物件名稱: 忠泰交響曲</strong><br />
地址: 中山區大直豪宅<br />
<strong>總價:</strong> 12800萬    (含車位)<br />
登記面積: 103.08坪    (車位坪數另計)<br />
公設面積: 28.84坪<br />
車位: 3個   (坡道/平面)<br />
屋齡: 0年<br />
隔局: 4 /2 /4衛<br />
座向: 朝南<br />
特色:1.水岸第一排，稀有頂樓景觀<br />
2.坐擁180度水岸，日夜美景<br />
3.忠泰制震豪宅，1500坪基地磅薄<br />
4.繼輕井澤、代官山、未來大直新指標</p>
<table width="400" border="0" cellpadding="2" cellspacing="0">
<tr>
<td valign="top" width="200"><a href="http://blog.eatdoku.com/wp-content/uploads/2008/07/auxiliarydisplaycpl.dll-i000f-0409.png"><img src="http://blog.eatdoku.com/wp-content/uploads/2008/07/auxiliarydisplaycpl.dll-i000f-0409-thumb.png" style="border: 0px none " alt="AuxiliaryDisplayCpl.dll_I000f_0409" width="244" border="0" height="155" /><br />
</a></td>
<td valign="top" width="200"></td>
</tr>
<tr>
<td valign="top" width="200"></td>
<td valign="top" width="200"><a href="http://blog.eatdoku.com/wp-content/uploads/2008/07/charmap.exe-i006f-0409.png"><img src="http://blog.eatdoku.com/wp-content/uploads/2008/07/charmap.exe-i006f-0409-thumb.png" style="border: 0px none " alt="charmap.exe_I006f_0409" width="244" border="0" height="155" /></a></td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://blog.eatdoku.com/?feed=rss2&amp;p=51</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Use Reflection to load User Control from &#8220;text&#8221; value</title>
		<link>http://blog.eatdoku.com/?p=44</link>
		<comments>http://blog.eatdoku.com/?p=44#comments</comments>
		<pubDate>Sat, 21 Jun 2008 04:49:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[Reflection]]></category>
		<category><![CDATA[User Control]]></category>

		<guid isPermaLink="false">http://blog.eatdoku.com/?p=44</guid>
		<description><![CDATA[Following is an exmpale of using reflection in .net to load user control in current assembly based on some text value provided. &#8220;CATUI.CATUserControls.ucMetadataProfiles&#8221;  full identifier of the usercontrol Type theType = Assembly.GetExecutingAssembly().GetType(&#8220;CATUI.CATUserControls.ucMetadataProfiles&#8221;); if (theType != null) { Object newObj = Activator.CreateInstance(theType); splitContainerMain.Panel2.Controls.Add((UserControl)newObj); }]]></description>
			<content:encoded><![CDATA[<p>Following is an exmpale of using reflection in .net to load user control in current assembly based on some text value provided.</p>
<p>&#8220;CATUI.CATUserControls.ucMetadataProfiles&#8221;  full identifier of the usercontrol</p>
<p>Type theType = Assembly.GetExecutingAssembly().GetType(&#8220;CATUI.CATUserControls.ucMetadataProfiles&#8221;);<br />
if (theType != null)<br />
{<br />
Object newObj = Activator.CreateInstance(theType);<br />
splitContainerMain.Panel2.Controls.Add((UserControl)newObj);<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eatdoku.com/?feed=rss2&amp;p=44</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Shutdown remote computer</title>
		<link>http://blog.eatdoku.com/?p=43</link>
		<comments>http://blog.eatdoku.com/?p=43#comments</comments>
		<pubDate>Thu, 19 Jun 2008 22:47:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://blog.eatdoku.com/?p=43</guid>
		<description><![CDATA[shutdown  -r -f -m \\computername]]></description>
			<content:encoded><![CDATA[<p>shutdown  -r -f -m \\computername</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eatdoku.com/?feed=rss2&amp;p=43</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Datetime compare in TSQL</title>
		<link>http://blog.eatdoku.com/?p=42</link>
		<comments>http://blog.eatdoku.com/?p=42#comments</comments>
		<pubDate>Mon, 16 Jun 2008 16:01:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[TSQL]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.eatdoku.com/?p=42</guid>
		<description><![CDATA[Original link Do not miss your data: the pitfalls of DATE and TIME in T-SQL. By Alfred Yomtov One of the frequently occurring querying problems in T-SQL is date time handling. While SQL Server 2005 is still not ANSI-92 standard compliant in supporting the standard set of DATE/TIME data types (that is DATE; TIME; DATE [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.msdn.microsoft.com/sqldt">Original link</a></p>
<p><span id="ctl00_ctl00_Content_TabContentPanel_Content_wikiSourceLabel"><strong>Do not miss your data: the pitfalls of DATE and TIME in T-SQL.</strong></span></p>
<ul>
<li>By Alfred Yomtov</li>
</ul>
<p>One of the frequently occurring querying problems in T-SQL is date time handling.</p>
<p>While SQL Server 2005 is still not ANSI-92 standard compliant<br />
in supporting the standard set of DATE/TIME data types (that is DATE; TIME; DATE + TIME),<br />
querying data with the DATETIME (millisecond accuracy) and<br />
SMALLDATETIME (minute accuracy) outcome in rather erroneous results.</p>
<p>Consider the following script that will create Tmp_Orders table with default order date:</p>
<p>CREATE TABLE dbo.Tmp_Orders<br />
(<br />
OrderID int NOT NULL IDENTITY (1, 1),<br />
OrderDate smalldatetime NOT NULL CONSTRAINT<br />
DF<em>Tmp</em>Orders_OrderDate DEFAULT (getdate()),<br />
ProductID int NOT NULL<br />
);</p>
<p>Therefore, on every occasion the order is added,<br />
current date and time are inserted in OrderDate field.</p>
<p>DECLARE @COUNTER AS TINYINT<br />
SET @COUNTER = 0<br />
WHILE (@COUNTER &lt; 5)<br />
BEGIN<br />
INSERT INTO Tmp_Orders (OrderDate, ProductID)<br />
VALUES (DATEADD(dd, FLOOR(RAND()*10), GETDATE()), FLOOR(RAND()*10 +1))</p>
<p>SET @COUNTER = @COUNTER + 1<br />
END;</p>
<p>DATEADD(dd, -FLOOR(RAND()*10), GETDATE()) will give us some random date with<br />
FLOOR(RAND()*10 +1) will give us random Product IDs</p>
<p>Let us select that is just entered:<br />
SELECT OrderID, OrderDate,ProductID<br />
FROM Tmp_Orders<br />
ORDER BY OrderDate;</p>
<p>•	-your resulted data will be different<br />
•	But assume those are added orders.</p>
<table>
<tr>
<td>5</td>
<td>2008-06-16 00:49:00</td>
<td>7</td>
</tr>
<tr>
<td>1</td>
<td>2008-06-19 00:49:00</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>2008-06-23 00:49:00</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>2008-06-24 00:49:00</td>
<td>8</td>
</tr>
<tr>
<td>3</td>
<td>2008-06-25 00:49:00</td>
<td>6</td>
</tr>
</table>
<p>Now let us set some criteria on Order Dates:</p>
<p>SELECT OrderID, OrderDate,ProductID<br />
FROM Tmp_Orders<br />
WHERE     (OrderDate BETWEEN  &#8217;16-Jun-2008&#8242; AND &#8217;25-Jun-2008&#8242;)<br />
ORDER BY OrderDate;</p>
<table>
<tr>
<td>5</td>
<td>2008-06-16 00:49:00</td>
<td>7</td>
</tr>
<tr>
<td>1</td>
<td>2008-06-19 00:49:00</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>2008-06-23 00:49:00</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>2008-06-24 00:49:00</td>
<td>8</td>
</tr>
</table>
<p>So, where is the order number 3, dated 2008-06-25?<br />
It still belongs to 25th of June 2008, but it is not in our result list!</p>
<p>Let us recall that internally DATETIME stored as 8-byte FLOAT number<br />
with decimal part representing number of dates since 01-Jan-1900 and fraction as a time.</p>
<p>So then querying our data with only DATE format (like BETWEEN &#8217;16-Jun-2008&#8242; AND &#8217;25-Jun-2008&#8242;) the time part is just sliced out.</p>
<p>To get the proper outcome, just convert our Order Date to float like that</p>
<p>SELECT OrderID, OrderDate,ProductID<br />
FROM Tmp_Orders<br />
WHERE   (CAST(FLOOR(CAST( OrderDate AS FLOAT )) AS DATETIME) BETWEEN   &#8217;16-Jun-2008&#8242; AND &#8217;25-Jun-2008&#8242;)<br />
ORDER BY OrderDate;</p>
<p>And the correct results will follow:</p>
<table>
<tr>
<td>5</td>
<td>2008-06-16 00:49:00</td>
<td>7</td>
</tr>
<tr>
<td>1</td>
<td>2008-06-19 00:49:00</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>2008-06-23 00:49:00</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>2008-06-24 00:49:00</td>
<td>8</td>
</tr>
<tr>
<td>3</td>
<td>2008-06-25 00:49:00</td>
<td>6</td>
</tr>
</table>
<p>Remember, DATETIME stored internally as a number, and converting it to something other than that is a slip-up<br />
and will leads only to inability of using any index on the DATETIME column.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eatdoku.com/?feed=rss2&amp;p=42</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ISNULL() and COALESCE()</title>
		<link>http://blog.eatdoku.com/?p=41</link>
		<comments>http://blog.eatdoku.com/?p=41#comments</comments>
		<pubDate>Wed, 16 Apr 2008 21:50:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[Sql Server]]></category>

		<guid isPermaLink="false">http://blog.eatdoku.com/?p=41</guid>
		<description><![CDATA[&#160; Original Post here In dealing with NULL values in SQL Server, the developer is often faced with the requirement to evaluate the content of a field, and when said field in null, return another value (or field). There are two functions in SQL Server which support this requirement: ISNULL() and COALESCE.() ISNULL COALESCE ISNULL [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>Original Post <a href="http://code.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=ISNULL_COALESCE&amp;referringTitle=Home" target="_blank">here</a></p>
<p>In dealing with NULL values in SQL Server, the developer is often faced with the requirement to evaluate the content of a field, and when said field in null, return another value (or field). There are two functions in SQL Server which support this requirement: ISNULL() and COALESCE.()   <br /><a href="http://code.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=ISNULL_COALESCE&amp;referringTitle=Home#ISNULL_Definition">ISNULL</a>    <br /><a href="http://code.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=ISNULL_COALESCE&amp;referringTitle=Home#COALESCE_Definition">COALESCE</a>    <br /><a href="http://code.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=ISNULL_COALESCE&amp;referringTitle=Home#ISNULL_vs_COALESCE">ISNULL vs. COALESCE</a>    <br /><a href="http://code.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=ISNULL_COALESCE&amp;referringTitle=Home#Performance">Performance Considerations</a>    <br /><a href="http://code.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=ISNULL_COALESCE&amp;referringTitle=Home#FurtherReading">Further Reading</a>    <br /><a name="ISNULL_Definition"></a></p>
<h6>ISNULL() </h6>
<p> ISNULL is a TSQL Function which is built into SQL Server. It is NOT a function defined by <a href="http://www.contrib.andrew.cmu.edu/%7Eshadow/sql/sql1992.txt">ANSI-92</a> &#8211; rather it is a feature which Microsoft has elected to include in TSQL in addition to the ANSI SQL standard.  <br /><a href="http://msdn2.microsoft.com/en-us/library/ms184325.aspx">ISNULL()</a> accepts two parameters. The first is evaluated, and if the value is null, the second value is returned (regardless of whether or not it is null). The following queries will return the second parameter in both cases:
<pre>SELECT ISNULL(NULL, 1)
--Returns 1
SELECT ISNULL(NULL, NULL)
--Returns NULL</pre>
<p><a name="COALESCE_Definition"></a></p>
<h6>COALESCE() </h6>
<p>COALESCE() is a TSQL function which, like ISNULL, is built into SQL Server. Unlike ISNULL, COALESCE is also a part of the <a href="http://www.contrib.andrew.cmu.edu/%7Eshadow/sql/sql1992.txt">ANSI-92</a> SQL Standard. Coalesce returns the first non-null expression in a list of expressions. The list can contain two or more items, and each item can be of a different data type. The following are valid examples of COALESCE:</p>
<pre>SELECT COALESCE(NULL, 1)
--Returns 1

SELECT COALESCE(NULL, 3, NULL, 1)
--Returns 3</pre>
<p><a name="ISNULL_vs_COALESCE"></a></p>
<h6>ISNULL vs. COALESCE </h6>
<p>Whenever multiple methods exist for addressing a single problem, the inevitable question is: which method is better? There are a few differences between the two functions which make COALESCE come out on top more often than not:</p>
<p>- COALESCE is ANSI-92 compliant. In the event that you need to port your code to another RDBMS, COALESCE will not require rework.</p>
<p>- COALESCE accepts greater than two expressions, whereas ISNULL accepts only two. In order to compare three expressions with ISNULL, you would have to nest expressions:</p>
<p>SELECT ISNULL(ISNULL(Col1, Col2), Col3)</p>
<p>- ISNULL constrains the result of a comparison of parameterrs to the datatype of the first value. For example, the following query will produce some often undesirable results using ISNULL, however it will behave as expected with COALESCE:</p>
<pre>DECLARE @Field1 char(3), @Field2 char(50)
SET @Field2 = 'Some Long String'

SELECT ISNULL(@Field1, @Field2)
--Returns 'Som'
SELECT COALESCE(@Field1, @Field2)
--Returns 'Some Long String'</pre>
<p><b>Note:</b> In other situations, COALESCE will produce <i>unexpected</i> results. COALESCE by nature promotes it&#8217;s arguments to the highest datatype among compatable arguments (arguments which are not explicitly case, and which aren&#8217;t compatable, will of course throw an error). When using COALESCE on an integer and a datetime, in that order, COALESCE will cast the integer as a datetime. For example:</p>
<p>SELECT COALESCE(5, GETDATE())</p>
<p>Will not return 5, it will return 1900-01-06 00:00:00.000 (5 as a datetime).</p>
<p><a name="Performance"></a></p>
<h6>Performance </h6>
<p>For most purposes, ISNULL and COALESCE perform in an almost identical fashion. It is generally accepted that ISNULL is slightly quicker than COALESCE, but not sufficiently to outweigh it&#8217;s inherent limitations. As with any performance related issue, if performance is a significant concern, write it both ways, and test!</p>
<p><a name="FurtherReading"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eatdoku.com/?feed=rss2&amp;p=41</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
