Rename column SQL Server 2008

前端 未结 12 2110
名媛妹妹
名媛妹妹 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:26

    Since I often come here and then wondering how to use the brackets, this answer might be useful for those like me.

    EXEC sp_rename '[DB].[dbo].[Tablename].OldColumnName', 'NewColumnName', 'COLUMN'; 
    
    • The OldColumnName must not be in []. It will not work.
    • Don't put NewColumnName into [], it will result into [[NewColumnName]].

提交回复
热议问题