HI All,
i have 2 databases x and y
a table in x named as table1
i am looking to copy 'table1' from database x to database y say named 'table2'
Database y doesnt have a table1
Version: SQL Server 2000
How to do this on Query Analyzer and/or Enterprise Manager?
Thanksuse this if table 2 does not exist in y.
select column1,column2
into y.dbo.table2
from x.dbo.table1
if table 2 does exist, use this...
INSERT INTO y.dbo.table2(column1,column2)
SELECT column1,column2
FROM x.dbo.table1|||Generate create table script and run it on y database then use import / export utility to transfer data.
SQL queries posted by Thrasymachus will also create new table and transfer data but if you need table dependent objects like triggers, constraints or indexes on your second database also, this way is useless.|||also, if you are copying millions of rows, better to use bcp with the -b flag.
otherwise your tlog will bloat.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment