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:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.