简体   繁体   English

如何以编程方式导入/导出SQL数据库表

[英]How To Import / Export SQL Database Tables Programmatically

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. 我尝试使用由我的自定义内部程序之一生成的大.SQL文件来执行此操作,但是由于300MB .sql文件,服务器用尽了内存。

How can I utilize SQL Server's Import feature via code in VB.Net? 如何通过VB.Net中的代码利用SQL Server的导入功能?

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. 您可以尝试使用其他方法作为服务器之间或其他“更多Admin”方法之间的数据复制,但是,如果要以编程方式进行操作,则可以创建DTS(数据转换包),然后使用石英等调度程序并通过以下方式执行DTS:您需要的时间表。

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. 这仅适用于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. 作为替代,你可能需要调用一个SSIS包所以看看到本教程实际的逻辑是一样的不管你决定使用DTS或SSIS包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM