<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" version="2.0"><channel><title>.NET Randz</title><link>http://devpinoy.org/blogs/dotnetrandz/default.aspx</link><description>Clipping of Thoughts as I Dabble with .NET World</description><dc:language>en</dc:language><generator>CommunityServer 2008 (Build: 30417.1769)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/netrandz" type="application/rss+xml" /><item><title>IsNullOrEmpty with a Twist on T-SQL</title><link>http://devpinoy.org/blogs/dotnetrandz/archive/2008/11/11/isnullorempty-with-a-twist-on-t-sql.aspx</link><pubDate>Tue, 11 Nov 2008 14:39:00 GMT</pubDate><guid isPermaLink="false">99090821-4da1-4a75-98c2-a35884625ff7:32289</guid><dc:creator>dotnetrandz</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://devpinoy.org/blogs/dotnetrandz/rsscomments.aspx?PostID=32289</wfw:commentRss><comments>http://devpinoy.org/blogs/dotnetrandz/archive/2008/11/11/isnullorempty-with-a-twist-on-t-sql.aspx#comments</comments><description>&lt;p&gt;This may be very elementary for others but I am happy to find a solution on my problem on finding the equivalent of .NET&amp;#39;s IsNullOrEmpty with a twist 
on T-SQL. It&amp;#39;s with a twist because I am hoping to find a similar solution that IsNull function is doing:
The T-SQL &lt;code style="font-size:12px;"&gt;&lt;span style="color:blue;"&gt;select&lt;/span&gt;&amp;nbsp;&lt;span style="color:#ff00dc;"&gt;isnull&lt;/span&gt;(columnName,&amp;nbsp;&lt;span style="color:red;"&gt;&amp;#39;Value&amp;nbsp;is&amp;nbsp;null&amp;#39;&lt;/span&gt;)&amp;nbsp;&lt;span style="color:blue;"&gt;from&lt;/span&gt;&amp;nbsp;myTable&lt;/code&gt;
&amp;nbsp; means return the value of &amp;#39;columnName&amp;#39; column if it is not null, otherwise, return &lt;code style="font-size:12px;"&gt;&lt;span style="color:red;"&gt;&amp;#39;Value&amp;nbsp;is&amp;nbsp;null&amp;#39;&lt;/span&gt;
&lt;/code&gt; string. &lt;/p&gt;
&lt;p&gt;I was hoping to extend this functionality by adding a check for empty string. So my search for &lt;code&gt;IsNullOrEmpty&lt;/code&gt; for T-SQL 
began.&lt;/p&gt;
&lt;p&gt;
The solution I found was actually very simple. No need for UDF. See below:
&lt;/p&gt;
&lt;p&gt;
&lt;code style="font-size:12px;"&gt;&lt;span style="color:blue;"&gt;select&lt;/span&gt;&amp;nbsp;Id,&amp;nbsp;&amp;nbsp;&lt;span style="color:#ff00dc;"&gt;isnull&lt;/span&gt;(&lt;span style="color:#ff00dc;"&gt;nullif&lt;/span&gt;(StreetName,&lt;span style="color:red;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;)+&lt;span style="color:red;"&gt;&amp;#39;,&amp;nbsp;&amp;#39;&lt;/span&gt;,&lt;span style="color:red;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;)&amp;nbsp;&lt;span style="color:blue;"&gt;from&lt;/span&gt;&amp;nbsp;Addresses&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This means, if the value of StreetName is not null or empty, return the value of StreetName plus the comma (,), otherwise, return an empty string.&lt;/p&gt;
&lt;p&gt;There may be a solution or solutions that addresses the same issue but with the limited time that I have, this is enough for me for now.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devpinoy.org/aggbug.aspx?PostID=32289" width="1" height="1"&gt;</description><category domain="http://devpinoy.org/blogs/dotnetrandz/archive/tags/T-SQL/default.aspx">T-SQL</category></item><item><title>And so it began...</title><link>http://devpinoy.org/blogs/dotnetrandz/archive/2008/11/07/and-so-it-began.aspx</link><pubDate>Fri, 07 Nov 2008 05:25:00 GMT</pubDate><guid isPermaLink="false">99090821-4da1-4a75-98c2-a35884625ff7:32087</guid><dc:creator>dotnetrandz</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://devpinoy.org/blogs/dotnetrandz/rsscomments.aspx?PostID=32087</wfw:commentRss><comments>http://devpinoy.org/blogs/dotnetrandz/archive/2008/11/07/and-so-it-began.aspx#comments</comments><description>&lt;p&gt;A great &lt;a target="_blank" title="Lao Tzu" href="http://www.quotationspage.com/quotes/Lao-tzu/"&gt;Chinese philosopher&lt;/a&gt; once said, &amp;quot;&lt;i&gt;A journey of a thousand miles begins with a single step&lt;/i&gt;.&amp;quot;&lt;/p&gt;
&lt;p&gt;Today, I am taking my first step in a journey that I hope will be fruitful and useful, both for me and whoever may have the chance to read my blogs.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devpinoy.org/aggbug.aspx?PostID=32087" width="1" height="1"&gt;</description><category domain="http://devpinoy.org/blogs/dotnetrandz/archive/tags/journey/default.aspx">journey</category></item></channel></rss>
