Exapli sp_rename in SQL SERVER 2008?

 Posted by CGN007 on 7/20/2012 | Category: Sql Server Interview questions | Views: 1844 | Points: 40
Answer:

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'


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response