Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to change a column name

Author  Topic 

kirknew2SQL
Posting Yak Master

194 Posts

Posted - 2008-01-09 : 10:26:50
I have created a table and found that i miss named a column. All i want to do is change the column name. But I don't see anything in ALTER TABLE to do that.

How do I simply change a column name?

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-01-09 : 10:51:35
check out "sp_rename" in books online.

exec sp_rename 'table.columnName', 'newColumnName'

Just be carefull that you aren't breaking any subsequent sql or application code. If this is a brand new table then I guess there is no risk of that. However, you could have some angry people around if you start re-naming existing columns

Be One with the Optimizer
TG
Go to Top of Page

kirknew2SQL
Posting Yak Master

194 Posts

Posted - 2008-01-09 : 11:00:47
Thanks for the info. This is all new work so nothing will break.

It is very surprising that something as simple as this is not part of the ALTER command.
Go to Top of Page
   

- Advertisement -