Renaming a column when using SQL
Its been a long time since I messed with a stored procedure. Well, I had a blonde moment and forgot how to rename a column when fetching data using a SQL SELECT call. Thanks to my awesome tweeps (@hasankhanbilal, @jeffa00, @TheToeFrog, and @mmuells) I was able to do this.
I needed to rename the ID column of the following example from:
SELECT tblSomeTable.ID FROM tblSomeTable
to
CustomerID
Well, apparently you can do this in three ways that I know of now. Below are the ways you can accomplish this.
1. SELECT tblSomeTable.ID “CustomerID” FROM tblSomeTable
2. SELECT tblSomeTable.ID AS ‘CustomerID’ FROM tblSomeTable
3. SELECT tblSomeTable.ID = ‘CustomerID’ FROM tblSomeTable
This is some great stuff. I really need to brush up on SQL once again. I have been using LINQ too much for my own good. Which do you prefer SQL or LINQ?
Boring code for boring work. zzzzzzzzz Can I work on something more interesting please?!


