Rename columns in SQL Server 2008 using Navicat
In SQL Server 2008, using a simple ALTER TABLE statement to modify column names may not produce the expected results. To overcome this problem, we use the sp_rename system stored procedure.
sp_rename stored procedure for column renaming
The syntax of sp_rename when renaming a column is as follows:
<code class="language-sql">EXEC sp_RENAME 'TableName.OldColumnName' , 'NewColumnName', 'COLUMN'</code>
Among them:
Code Example
For your scenario, the following code will rename the old_name column in table table_name to new_name:
<code class="language-sql">EXEC sp_RENAME 'table_name.old_name', 'new_name', 'COLUMN'</code>
Additional Notes
The above is the detailed content of How to Rename Columns in SQL Server 2008 Using `sp_rename`?. For more information, please follow other related articles on the PHP Chinese website!