如何将数据从一个服务器表复制或移动到另一服务器表. [英] How to copy or move data from one server table to another server table.

查看:91
本文介绍了如何将数据从一个服务器表复制或移动到另一服务器表.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用两个服务器.就像server1到server2.

我想将表数据从server1移动或复制到server2表.

我正在使用以下查询.但是,它不起作用.

从server1.dbo.dbname1.table1中选择*到server1.dbo.dbname1.table1

I am using two server. like server1 to server2.

i want to move or copy table data from server1 to server2 table.

i am using below query. but, it''s not working.

select * into server1.dbo.dbname1.table1 from server1.dbo.dbname1.table1

Is there any other way to write the query..?

推荐答案

您还可以使用SQL Management Studio中的导入/导出数据任务.

右键单击您的数据库->选择任务,然后根据您的源表或目标表选择导入/导出数据.

如何:运行SQL Server导入和导出向导
http://msdn.microsoft.com/en-us/library/ms140052.aspx


您还可以使用
You can also use import/export data task from SQL management studio.

Right click on your datbase -->Select Tasks and select import/export data based on your source or destination table.

How to: Run the SQL Server Import and Export Wizard
http://msdn.microsoft.com/en-us/library/ms140052.aspx


You can also use the Generate SQL Server Scripts Wizard[^] to help guide the creation of SQL script''s that can do the following:

copy the table schema
any constraints (identity, default values, etc)
data within the table
and many other options if needed


您需要将服务器添加为链接服务器.这样您的查询才能正常工作.

另请注意,查询中的servername.dbo.tablename ....中的分隔符不应超过三个.否则它将无法正常工作
You need to add the server as linked server. Then your query will work correctly.

Also note that there should not be more than three ''.'' separators in the servername.dbo.tablename.... in your query. Otherwise it will not work


1.两个服务器都有单独的连接对象.
2.从一台服务器获取数据并将其保存在内存中(数据表或数据集)
3.使用第二个连接将该数据写入.
1. Have separate connection objects for both servers.
2. fetch the data from one server and keep it in memory(datatable or dataset)
3. use second connection to write this data into.


这篇关于如何将数据从一个服务器表复制或移动到另一服务器表.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆