Reputation: 176
I have two different servers. I need to transfer the data from One Server table to another server table (both are on same structure) using either BCP
or using BULK INSERT
. I need to do this on the run time. Can anybody please help me on this? I have a linked share
connection established between the servers. Looking for an option to copy data faster.
Upvotes: 3
Views: 4260
Reputation: 5274
BCP will almost certainly the fastest, however it is not transactional and the error trapping is rather poor. It's pretty easy to use though, let's say you have server1
and server2
each having a the_database
and the_table
with the same structure.
server1
go to your command line, start->run->cmd
not Microsoft SQL Management Studio.bcp the_database.dbo.the_table out c:\the_data.txt -T -E
the_data.txt
to c:\
on server2
server2
TRUNCATE
the_table (unless you want to append, but watch for constraint problems)server2
, once again go to command linebcp the_database.dbo.the_table in c:\the_data.txt -T -E
That will be your fastest solution. You can also use the IMPORT
or EXPORT
wizards inside of Microsoft SQL Management Server which is more of a GUI way to do the same thing, but the cmd
way will be the fastest way to just copy massive amounts of data (millions of rows). If you simply type bcp
from command line you'll see lots of options.
Nothing wrong with doing bulk insert
across servers for but raw caveman power 'copy data fast' this is the fastest way to do it, imho.
Upvotes: 4