Home >Database >Mysql Tutorial >How to Rename Columns in SQL Server 2008?
SQL Server 2008: Efficient Column Renaming
In SQL Server 2008, the standard ALTER TABLE
command for renaming columns may not function as expected. The recommended approach is to utilize the sp_rename
stored procedure.
Here's the correct syntax:
<code class="language-sql">EXEC sp_RENAME 'TableName.OldColumnName', 'NewColumnName', 'COLUMN';</code>
For instance, to change "old_name" to "new_name" in the table "table_name":
<code class="language-sql">EXEC sp_RENAME 'table_name.old_name', 'new_name', 'COLUMN';</code>
Ensure all names are enclosed in single quotes. Consult the official Transact-SQL documentation for sp_rename
for comprehensive details and further assistance.
The above is the detailed content of How to Rename Columns in SQL Server 2008?. For more information, please follow other related articles on the PHP Chinese website!