Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: SQL Server
Expertise: Beginner
Apr 17, 2000



Application Security Testing: An Integral Part of DevOps

Renaming a SQL Column

Can I rename a SQL column without making a new table or relying on GUI?

The ALTER TABLE ALTER COLUMN SYNTAX supports either dropping an existing column or altering the type. But it doesn't allow you to change the name.

However, another command, sp_rename, will allow you to change the name of a column. It takes three arguments: the name of the object, the new name, and the object type.

Following is an example taken from the Books Online:

B. Rename a column This example renames the contact title column in the customers table to title.
EXEC sp_rename 'customers.[contact title]', 'title', 'COLUMN'
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date