Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Transferrig tables from one db to another db

Author  Topic 

prashanth_gs
Starting Member

1 Post

Posted - 2005-11-07 : 06:31:39
Hai,

We have two databases and we need to transfer the tables from one database to another database.

What are the ways to do the same.

Is this command work out, if not pls provide the correct method...

COPY from user/pwd@dba1 to user1/pwd@dba2
INSERT INTO TABLE2 USING SELECT * FROM TABLE1

please help us...

Thanx in advance,
Prashant

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-07 : 06:37:07
Use any one of the following

1 Use DTS
2 Use Import/Export option thru Enterprise Management
3 Use queries like this

Insert into DB1.dbo.Table1(columns) Select columns from DB2.dbo.Table1

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2005-11-07 : 06:39:58
For the data migration from one database to another database you can make use of DTS i.e Data Transformation Service..

or if you just want to transfer 1 or 2 tables then you can tryout the following query ..

Using <DestinationDatabase>

Select * Into <TableName> From <SourceDatabase>..<TableName>

This query will create the table as the same structer and will migrate all the data from the sourcetable to the destination table

But it will not create any indexes or primary key.. if there were any in the source table.

Complicated things can be done by simple thinking
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2005-11-07 : 08:35:34
Or dmo
http://www.mindsdoor.net/DMO/SQL-DMOTransfer.html

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-11-07 : 12:59:53
Why?

Sounds like a waste if they're on the same server....



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page
   

- Advertisement -