This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing a T-SQL script for changing or moving tables between the schema of SQL Server.
Copy table between servers, databases, schemas is a common requirement for all DBs. DBO is a default schema of a SQL Server. If you want to move your existing table into some other schema, you can try below script.
Change the schema of a table:
1 2 |
ALTER SCHEMA target_schema TRANSFER dbo.table_name; |
Move all tables into another table:
1 |
exec sp_MSforeachtable "ALTER SCHEMA target_schema TRANSFER ?" |