26 November 2008

"Renaming" fields within table

Today I have to change the name of one column within my ms sql database.
I wanted to come up with the script that will do it for me.
I figured that ms sql discourage use of altering column names, rather they want you to drop and then recreate column using following sql:


ALTER TABLE TableName DROP COLUMN ColumnName

ALTER TABLE TableName ADD ColumnName datatype NULL


I haven't spent much time exploring further possibility of "renaming" column that exists with oracle. If something like this is possible with ms sql 2005 I would like to hear?

No comments: