Search
Winners

Win Prizes

Social Presence
Twitter Twitter LinkedIn YouTube Google

Like us on Facebook
Advertisements
Top Codes Author
Thu, 28-Aug-2014 Authors
All Time Authors
Satyapriyanayak
12160
Jayakumars
8120
Niladri.biswas
6000

Latest members | More ...


(Statistics delayed by 5 minutes)
 Codes

Renaming table/column using sp_rename in SQL SERVER 2008

CGN007
Posted by CGN007 under Sql Server on 6/29/2012 6:06:02 AM | Points: 40 | Views : 2525 | Status : [Member]

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'


Found interesting? Add this to:



Comments or Responses


Login to post response