SQL数据传输
我需要将数据从一个表传输到另一台已被截断的服务器中的同一个表。 做到这一点最简单的方法是什么?
I need to transfer data from one table to the same table in another server which has been truncated. What is the easiest way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
设置链接服务器,然后在目标数据库:
Setup linked servers and then use the following on the destination database:
使用 SQL Server 导入和导出向导。 这可能是完成此任务的最简单方法。
对于更高级的数据传输,请考虑使用
bcp
实用程序、BULK INSERT
语句和OPENDATASOURCE
。Use the SQL Server Import and Export wizard. It's probably the easiest way to accomplish this task.
For more advanced data transfer, consider using
bcp
utility,BULK INSERT
statement andOPENDATASOURCE
.将一台服务器上的表备份到一个文件,然后将该文件恢复到另一台服务器上的空表中...
Back up the table on the one server, to a file, and restore that file into the empty table on the other one...
我会使用数据转换服务(又名集成服务)。
I would use Data Transformation Services (aka Integration Services).
取决于数据传输的数量和频率。 如果这是一个低容量的一次性过程,您最好使用 T-SQL 直接插入数据。 这可以通过链接服务器或 OPENQUERY 子句来完成。
如果一次性进程容量较大,请使用 SSIS 或 BCP 实用程序。
如果其数量大、频率高,请使用复制。
Depending on the amount and frequency of your data transfer. It it's a low volume one time process, you're better off with using T-SQL to directly insert the data. This can be done either through linked servers or OPENQUERY clause.
If its high volume one time process, use SSIS or BCP utility.
If its high volume high frequency, use replication.
这是我喜欢用于此目的的脚本。 易于使用,并且基本上没有错误。 只需将下面的文本复制到查询窗口中,然后按照说明进行操作即可。 运行它后,您将拥有一堆可以在其他服务器上运行的插入语句。
This is the script I like to use for this. Easy to use, and is mostly bug-free. Just copy the text below into your query window, and follow the directions. After you run it you will have a bunch of insert statements that you can run on the other server.