How to move a table to another schema

The topic contains information on how to transfer a table from one schema to another.

To transfer a required object, follow the steps below:

  1. Open the comparison wizard.
  2. On the Source and Target tab specify the schema where you want to insert the table in.

    Source and Target Tab

  3. Switch to the Mapping tab, and specify the schema you want to move.
  4. Check Compare only mapped schemas.

    Source and Target Tab

  5. Click the Compare button.
  6. Having compared two schemas, click Synchronize, or press F8. The synchronization wizard opens.
  7. Check the Use ALTER SCHEMA TRANSFER expression option on the Options tab of the synchronization wizard.

    Options Tab

  8. Click Synchronize.
  9. 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
    
  10. 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

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge Studio for SQL Server.
All Features

All features

Get acquainted with the rich features and capabilities of the Studio in less than 5 minutes.
Request a demo

Request a demo

If you consider employing the Studio for your business, request a demo to see it in action.
Ready to start using dbForge Studio for SQL Server?