Transferring Tables from Different Schemas

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.