How to move a table to another schema
Last modified: October 1, 2024
The topic contains information on how to transfer a table from one schema to another.
To transfer a required object, follow the steps below:
- Open the comparison wizard.
-
On the Source and Target tab specify the schema where you want to insert the table in.
- Switch to the Mapping tab, and specify the schema you want to move.
-
Check Compare only mapped schemas.
- Click the Compare button.
- Having compared two schemas, click Synchronize, or press F8. The synchronization wizard opens.
-
Check the Use ALTER SCHEMA TRANSFER expression option on the Options tab of the synchronization wizard.
- Click Synchronize.
- The script example modifies the schema sc1 by transferring the table sc1.table1 from schema sc2 into the schema:
create schema sc1; GO create schema sc2; GO create table sc1.table1 (id int); GO
- The resultant script will be displayed as follows:
ALTER SCHEMA sc2 TRANSFER sc1.table1 GO
Note
- You can only transfer tables between schemas from the same database.
- All permissions associated with the table that is being transferred are dropped when it is moved.
- Only beginning with SQL Server 2005, the Transfer option is available.
Download dbForge Studio for SQL Server and try it absolutely free for 30 days!
Want to find out more?
Overview
Take a quick tour to learn all about the key benefits delivered by dbForge Studio for SQL Server.
All features
Get acquainted with the rich features and capabilities of the tool in less than 5 minutes.
Request a demo
If you consider employing this tool for your business, request a demo to see it in action.