Rename column SQL Server 2008

前端 未结 12 2172
名媛妹妹
名媛妹妹 2020-11-27 08:52

I am using SQL Server 2008 and Navicat. I need to rename a column in a table using SQL.

ALTER TABLE table_name RENAME COLUMN old_name to new_name;

12条回答
  •  鱼传尺愫
    2020-11-27 09:27

    You can use sp_rename to rename a column.

    USE YourDatabase;  
    GO  
    EXEC sp_rename 'TableName.OldColumnName', 'NewColumnName', 'COLUMN';  
    GO  
    

    The first parameter is the object to be modified, the second parameter is the new name that will be given to the object, and the third parameter COLUMN informs the server that the rename is for the column, and can also be used to rename tables, index and alias data type.

提交回复
热议问题