[英]How do you transfer all tables between databases using SQL Management Studio?
When I right click on the database I want to export data from, I only get to select a single table or view, rather than being able to export all of the data. 当我右键单击要从中导出数据的数据库时,只能选择一个表或视图,而不能导出所有数据。 Is there a way to export all of the data? 有没有办法导出所有数据?
If this is not possible, could you advise on how I could do the following: 如果这不可能,您能建议我如何执行以下操作:
I need to get all of the additional data from the larger database, into the smaller database. 我需要将所有其他数据从较大的数据库获取到较小的数据库。
Both are MS SQL databases 两者都是MS SQL数据库
Being that both are MS SQL Servers, on different hosts... why bother with CSV when you can setup a Linked Server instance so you can access one instance from the other via a SQL statement? 两者都是在不同主机上的MS SQL Server ...为什么在设置Linked Server实例以便可以通过SQL语句从另一个实例访问一个实例时又打扰CSV?
Reference the name in queries using four name syntax: 使用四种名称语法在查询中引用名称:
INSERT INTO db1.dbo.SmallerTable SELECT * FROM linked_server.db.dbo.LargerTable lt WHERE NOT EXISTS(SELECT NULL FROM db1.dbo.SmallerTable st WHERE st.col = lt.col)
Replace WHERE st.col = lt.col
with whatever criteria you consider to be duplicate values between the two tables. 将WHERE st.col = lt.col
替换为您认为是两个表之间重复值的任何条件。
There is also a very good tool by Redgate software that syncs data between two databases. Redgate软件还有一个非常好的工具,可以在两个数据库之间同步数据。
I've also used SQL scripter before to generate a SQL file with insert statements that you can run on the other database to insert the data. 之前,我还使用过SQL脚本编写器来生成带有插入语句的SQL文件,您可以在其他数据库上运行该语句来插入数据。
If you right-click on the database, under the Tasks menu, you can use the Generate Scripts option to produce SQL scripts for all the tables and data. 如果右键单击数据库,则在“任务”菜单下,可以使用“生成脚本”选项为所有表和数据生成SQL脚本。 See this blog post for details. 有关详细信息,请参见此博客文章 。 If you want to sync the second database with the first, then you're better off using something like Redgate as suggested in mpenrow's answer. 如果要与第二个数据库同步,那么最好使用mpenrow答案中建议的Redgate之类的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.