Link to home
Start Free TrialLog in
Avatar of mustang61
mustang61

asked on

Insert Into SQL Server from another SQL Server using VB 2008

Is it possible to use Visual Basic to copy data from a sql server to a remote sql server?

If so what is the easiest way to do it?
Avatar of Raja Jegan R
Raja Jegan R
Flag of India image

Try the steps below:

1. Establish two connection strings and connect to both servers
2. Fetch records from one Server
2a. If records are huge, dump records into a flat file and then insert from that temp file to another server.
3. Insert into another server.
Avatar of mustang61
mustang61

ASKER

I created the 2 connections - i am a vb beginner - is the code easy to write to insert the table from one to another on different servers?
Code is easy but its just the performance side which you need to consider.

Open connection to server1
open connection to server2
use a command and datareader to read server 1

While DataReader.Read
     command2.commandtext = "Insert into ..."
     command2.executenonquery
End While
these tables are not large and once the initial copy is done it will be only addons based upon on yes/no checlbox
Then the manual row by row copy should be fine
the example is written in 'C' - not good at converting
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Worked to perfection - THANKS!
Glad to help :-)