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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Sqlscript along with data of a table

Author  Topic 

anupalavila
Yak Posting Veteran

56 Posts

Posted - 2008-12-03 : 05:54:43
Hai
How can I transfer a table from database DB1 to another database DB2 along with the data in it. Usually I use to generate sqlscript of the table and run in other database but now I need also the data in it, Is there any way like generating sqlscript together with the data in it

Thanks and Regards
Anu Palavila

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-12-03 : 07:45:30
You can do like this:
select *
into db2..table1
from db1..table1
The target table then is created by the query. You have to alter table for missing indexes etc.

or you can use DTS-Package, there is task to copy server objects.

Greetings
Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-03 : 09:16:30
Are dbs in same server? if yes,use webfred's soln. else,either add them as linked server and use
select * 
into server2.db2..table1
from server1.db1..table1


else use OPENROWSET
Go to Top of Page

anupalavila
Yak Posting Veteran

56 Posts

Posted - 2008-12-03 : 23:25:24
no the dbs are on different servers one in my local machine and the other in a hosting server where I use to host my website

Thanks and Regards
Anu Palavila
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-04 : 02:16:54
quote:
Originally posted by anupalavila

no the dbs are on different servers one in my local machine and the other in a hosting server where I use to host my website

Thanks and Regards
Anu Palavila


then try my last suggestion
Go to Top of Page
   

- Advertisement -