Test your technical skills online, appear in Virtual Interview and be ready for job!
Twitter Twitter LinkedIn YouTube Google
Be Interview ready ! | Search
Make friends on DotNetFunda.com and expand your network!
Winners

Win Prizes

Announcements
Like us on Facebook
Sponsor
Top Codes Author
Wed, 23-Apr-2014 Authors
Zondray
40
All Time Authors
Satyapriyanayak
11600
Jayakumars
8120
Niladri.biswas
6000

Latest members | More ...


(Statistics delayed by 5 minutes)

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 : 2152 | 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.

Comments / Responses
Select text & click toolbar to format. Formatting appears in viewmode only. HTML Tags are not allowed.
Bold Italic Underline Paragraph Title Code  Link 
 Wait ... Processing ..... please wait.