Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

column name change

Status
Not open for further replies.

denimblue

Technical User
Sep 23, 2002
8
US
How do I change a column name in MS SQL 7? I have data in two columns reversed. Can I change the column names or do I have to move the data? Can anyone assist with the proper sql query statement.
 
The easiest way to make the change would be through Enterprise Manger table designer. In T-SQL, you can use the system stored procedure sp_rename. You'll have to make the changes in three steps.

exec sp_rename '[tablename].[col1]','colX','Column'
exec sp_rename '[tablename].[col2]','col1','Column'
exec sp_rename '[tablename].[colX]','col2','Column' Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top