Copy all rows from one table to another new table in MSSQL

When you want to create a new table in a Database B and fill it with the rows of another table in Database A, then you can use the SELECT … INTO format like in the following query:

SELECT * INTO [DatabaseB].[dbo].[customer]
FROM [DatabaseA].[dbo].[customer]

Here are some important notes for this query:

If you want to rename the columns in the new table and copy the content from the old table, then use the following query:

INSERT INTO [DatabaseB].[dbo].[customer]
SELECT oldColumn1,
FROM [DatabaseA].[dbo].[customer]

More information about the INTO keyword can be found here.

comments powered by Disqus