Geeks With Blogs
AzamSharp Some day I will know everything. I hope that day never comes.

Yesterday, I was working on a page and for some reason it was not returning the correct results. I checked the stored procedure and everything was there. It was a much bigger stored procedure which was returning integar values but here is a small example.

SELECT [id],CategoryName Description from categories

Initially, when I checked the results using the UI it seemed like the CategoryName is messed up since it is returning strange results (even though only the name of the column was changed to Description and it was still CategoryName). So, I checked the sproc again and found out that the comma was missing and because of that the CategoryName has an alias of Description.

I am no database expert but I think it should be a good idea to have some sort of feature in SQL SERVER so that the ALIAS can only be declared using the AS keyword. This way we can avoid this problem. Although I don't think these kind of problems happens everyday.

Posted on Thursday, February 21, 2008 6:15 AM | Back to top

Comments on this post: Use AS Keyword When Giving Alias to Columns (T-SQL)

# re: Use AS Keyword When Giving Alias to Columns (T-SQL)
Requesting Gravatar...
Just got bit by the same bug, only this sp was buried three calls deep in a web service!
Left by Joe Jalbert on May 22, 2008 1:44 AM

Your comment:
 (will show your gravatar)

Copyright © Mohammad Azam | Powered by: