Move a table from one database to another database SQL Server Move a table from one database to another database SQL Server sql-server sql-server

Move a table from one database to another database SQL Server


If the databases are on same server then do it like this,

select * into DB_2.T1 from DB_1.[dbo].[T1]

if you have databases on different servers than you have to create a linked server.

On second thought you can generate "create tables scripts" and run them on second database


In SQL Server Management Studio you have Import and Export Wizard :

  1. Right click on db name(DB_2)
  2. Tasks
  3. Import Data
  4. Choose data source (DB_1)
  5. Choose destination (DB_2)
  6. Choose copy data from one ore more tables
  7. Choose your table (T1)
  8. Finish


With help of my office friends , this is the solution I figured out.

  1. In object Explorer , go to source database and select table to move.

  2. Right click , Script Table As -> CREATE TO -> New Query Editor Window. This opens query window with the SQL queries specifying schema , indexes , constraints on the table.

  3. You can change table name in CREATE TABLE section and make other changes...

  4. Change database name in first line USE <DATABASE> to Target database and execute the the query.

Thanks.