I often get request from blog reader for T-SQL script to rename database table column name or rename table itself.
1:-The script for renaming any column :
sp_RENAME 'TableName.[OldColumnName]' , '[NewColumnName]', 'COLUMN'
example:- sp_Rename 'employee.eid','employeeid','column'
2:-The script for renaming any object (table, sp etc) :sp_RENAME '[OldTableName]' , '[NewTableName]'
example:- sp_Rename 'employee','newemployee'
he... heee
ReplyDelete