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
 rename a column in sql table

Author  Topic 

mavericky
Posting Yak Master

117 Posts

Posted - 2011-09-27 : 09:46:18
Hi All,
Is there any way I can rename a column in sql table with code? I dont want to rename it manually.


Thanks,
Mavericky

vmvadivel
Yak Posting Veteran

69 Posts

Posted - 2011-09-27 : 10:18:29
EXEC sp_rename
@objname = 'YourTableName.YourOldColumnName',
@newname = 'YourNewColumnName',
@objtype = 'COLUMN' --- this stays as it is

Best Regards
Vadivel

http://vadivel.blogspot.com
Go to Top of Page

mavericky
Posting Yak Master

117 Posts

Posted - 2011-09-27 : 10:44:10
is sp_rename an inbuilt stored proc or will i have to make it?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-27 : 11:34:53
its a system stored proc. you just need to call it as shown

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -