Home > Codes >

Renaming table/column using sp_rename in SQL SERVER 2008

CGN007
Posted by CGN007 under Sql Server category on | Points: 40 | Views : 3105
Renaming table/column using sp_rename in SQL SERVER 2008

sp_rename

sp_rename [ @objname = ] 'object_name' , [ @newname = ] 'new_name' 

[ , [ @objtype = ] 'object_type' ]


Simple syntax

Renaming any column :
sp_RENAME 'Table_Name.[Old_Column_Name]' , '[New_Column_Name]', 'COLUMN'


Renaming any object (table, sp etc) :
sp_RENAME '[Old_Table_Name]' , '[New_Table_Name]'


Example
 sp_rename 'employee.name','fullname','COLUMN"

 sp_rename 'employee','employeedetails'

Comments or Responses

Login to post response