How to change a table name using an SQL query?

后端 未结 10 1910
北海茫月
北海茫月 2020-12-12 17:05

How can I in change the table name using a query statement?

I used the following syntax but I couldn\'t find the rename keyword in SQL server 2005.

A         


        
10条回答
  •  时光说笑
    2020-12-12 17:34

    Use sp_rename:

    EXEC sp_rename 'Stu_Table', 'Stu_Table_10'
    

    You can find documentation on this procedure on MSDN.

    If you need to include a schema name, this can only be included in the first parameter (that is, this cannot be used to move a table from one schema to another). So, for example, this is valid:

    EXEC sp_rename 'myschema.Stu_Table', 'Stu_Table_10'
    

提交回复
热议问题