How to rename a table in SQL Server?

后端 未结 8 1097
忘了有多久
忘了有多久 2020-12-12 10:10

The SQL query that I have used is :

ALTER TABLE oldtable RENAME TO newtable;

But, it gives me an error.

8条回答
  •  有刺的猬
    2020-12-12 10:53

    To rename a table in SQL Server, use the sp_rename command:

    exec sp_rename 'schema.old_table_name', 'new_table_name'
    

提交回复
热议问题