Search
Weekend Training
ASP.NET MVC, HTML 5 weekend training, click here
eBook free
Winners

Win Prizes

Social Presence
Twitter Twitter LinkedIn YouTube Google

Like us on Facebook
Advertisements
Top Codes Author
Fri, 30-Jan-2015 Authors
Bandi
1360
All Time Authors
Vishal@Neeraj
12960
Satyapriyanayak
12160
Jayakumars
8120

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 : 2805 | 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'


Share this to:

Bookmark It

Comments or Responses


Login to post response