all groups > sql server new users > july 2006 >
You're in the

sql server new users

group:

Copying tables from one DB to anotherq


Re: Copying tables from one DB to anotherq Arnie Rowland
7/19/2006 8:42:58 AM
sql server new users:
For a few tables, it's as simple as a query.

This will both create the table and transfer the data. However, you will =
then need to deal with indexes, keys, constraints, etc.

SELECT ( * | ColumnList )
INTO NewTable
FROM oldserver.database.dbo.table
WHERE ( Criteria )

This will transfer the data. (NewTable must exist.)

INSERT INTO NewTable
SELECT ( * | ColumnList )
FROM oldserver.database.dbo.table
WHERE ( Criteria )

If you have to transfer a large number of tables, or this is something =
that must occur again, you would be better off checking out DTS (SQL =
2000) or SSIS (SQL 2005). With either of those tools (included with SQL =
Server), you can transfer table schema, including keys, indexes, =
constraints, etc., as well as data. And you can save the instructions =
(Package) to run again.

I hope this helps.

--=20
Arnie Rowland
Most good judgment comes from experience.=20
Most experience comes from bad judgment.=20
- Anonymous


[quoted text, click to view]
Copying tables from one DB to anotherq darrel
7/19/2006 9:50:33 AM
I need to migrate some data from one DB on one DB server to another DB on
another DB server. Can that be done from a SQL query or is this more
involved due to the tables existing on separate physical servers?

-Darrel


AddThis Social Bookmark Button