SQL Server – Copy Table Schema and Data From One Database to Another Database

Updated on     Kisan Patel

Problem:

How to Copy Table Schema and Data From One Database to Another Database in SQL Server?

Solution:

If you want to copy SQL Server Table schema and data to another database then follow below approach:

If you want to copy only the structure or the schema of the table, then use below query:

select * into <destination_database.dbo.destination> from _
<source_database.dbo.source> where 1 = 2

If you want to copy a table in the same database, then use below query:

select * into newtable from SourceTable

If you want to copy a table schema with data to another database, then use below query:

select * into DestinationDB.dbo.tableName from SourceDB.dbo.SourceTable

If you want to copy only table data to another table, then use below query:

INSERT INTO table2
SELECT * FROM table1;

SQL Server

Leave a Reply