2

I am trying to import all of a Database's information to another Database just as I would when doing it with the user interface.

I tried to do it with a large .SQL file generated by one of my custom inhouse programs, but the server runs out of memory due to a 300MB .sql file.

How can I utilize SQL Server's Import feature via code in VB.Net?

2
  • Can you use replication, service broker? Commented Mar 5, 2014 at 17:03
  • Why don't you just run a loop through the tables of the first database and grab a few thousand lines at a time and send them to the second database? Eventually all will be sent over. Do you know how to connect to the database and read in data in vb.net? Commented Mar 5, 2014 at 17:23

1 Answer 1

1

You can try to use other methods as data replications between servers or another "more Admin" approcach, but if you want to do it programatically you can create a DTS (data transformation package), then use a scheduler like quartz and execute your DTS with the schedule you need it.

Dim dtsp As New DTS.Package
    dtsp.LoadFromSQLServer _
        ServerName:="MyServer", _
        ServerUserName:="MyUserID", _
        ServerPassword:="MyPassword", _
        PackageName:="DTSDemo"
    dtsp.Execute

take a look to the reference this may help you out.

That only will work on previous versions to SQL 2012.

as an alternative you may want to call a SSIS package so take a look to this tutorial practically the logic is the same whatever you decide to use a DTS or a SSIS package.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.