Thursday, January 27, 2011

SQL Server: Renaming Database Column, Table Name

Often we get requirement to rename database column or table.
Here the syntax to do it using T-SQL scripts.

Script to rename any column

sp_RENAME 'tableName.OldColumnName' , 'NewColumnName', 'Column'
GO

Script to rename any db object (table, sp etc)

sp_RENAME 'objectOldName', 'objectNewName'
GO

Reference: DP (http://dptechnicalblog.blogspot.com/)

No comments:

Post a Comment