.NET Randz

Clippings of Thoughts as I Dabble with .NET World
IsNullOrEmpty with a Twist on T-SQL

This may be very elementary for others but I am happy to find a solution on my problem on finding the equivalent of .NET's IsNullOrEmpty with a twist on T-SQL. It's with a twist because I am hoping to find a similar solution that IsNull function is doing: The T-SQL select isnull(columnName, 'Value is null'from myTable   means return the value of 'columnName' column if it is not null, otherwise, return 'Value is null' string.

I was hoping to extend this functionality by adding a check for empty string. So my search for IsNullOrEmpty for T-SQL began.

The solution I found was actually very simple. No need for UDF. See below:

select Id,  isnull(nullif(StreetName,'')+', ',''from Addresses.

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.

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.

Posted: 11-11-2008 10:39 PM by dotnetrandz | with 4 comment(s)
Filed under:
And so it began...

A great Chinese philosopher once said, "A journey of a thousand miles begins with a single step."

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.

Posted: 11-07-2008 1:25 PM by dotnetrandz | with 4 comment(s)
Filed under: