Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 41744 |  Welcome, Guest!   Register  Login
 Home > Interview Questions > SQL Server Interview Questions > Exapli sp_rename in SQL SERVER 2008? ... ...

Exapli sp_rename in SQL SERVER 2008?

Interview question and answer by: CGN007 | Posted on: 7/20/2012 | Category: SQL Server Interview questions | Views: 569 | | Points: 40
Ads
Ads


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 
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

Even more ... | Submit Interview Questions and win prizes!

More Interview Questions from CGN007

Even more ... | Submit Interview Questions and win prizes!


About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 6/19/2013 8:53:39 AM