Home > Database > Mysql Tutorial > How to Rename Columns in SQL Server 2008?

How to Rename Columns in SQL Server 2008?

Susan Sarandon
Release: 2025-01-07 16:07:40
Original
217 people have browsed it

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:

EXEC sp_RENAME 'TableName.OldColumnName', 'NewColumnName', 'COLUMN';
Copy after login

For instance, to change "old_name" to "new_name" in the table "table_name":

EXEC sp_RENAME 'table_name.old_name', 'new_name', 'COLUMN';
Copy after login

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template