Renaming multiple tables

前端 未结 4 393
忘了有多久
忘了有多久 2020-12-07 03:31

In SQL Server, I have a database abc. In this database I have hundreds of tables. Each of these tables is called xyz.table

I want to change

4条回答
  •  无人及你
    2020-12-07 04:18

    I'm assuming You've already created the schema abc in the database.

    If not you can refer here

    http://www.youtube.com/watch?v=_DDgv8uek6M

    http://www.quackit.com/sql_server/sql_server_2008/tutorial/sql_server_database_schemas.cfm

    To change the schema of all the tables in database you can use following system created msforeachtable stored procedure to rename schema of each table with alter schema.

    exec sp_MSforeachtable "ALTER SCHEMA abc TRANSFER ? PRINT '? modified' "
    

提交回复
热议问题