将表数据从一个SQL Server导出到另一个 [英] Export table data from one SQL Server to another

查看:272
本文介绍了将表数据从一个SQL Server导出到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个SQL Server(2005版本)。



我想将多个表从一个表移植到另一个。



我试过:




  • 在源服务器上,我右键点击了数据库,选择了任务/生成脚本
    问题是在表/视图选项下没有脚本数据选项。


  • 然后我使用脚本表As / Create脚本生成SQL文件,以便在目标服务器上创建表。但是我仍然需要所有数据。




然后我尝试使用:



pre> SELECT *
INTO [destination server]。[destination database]。[dbo]。[destination table]
FROM [source server]源数据库] [dbo]。[源表]

但是我收到错误:


对象包含超过最大数量的前缀。最高是
2。


有人可以指出我正确的解决我的问题吗?

解决方案

尝试这样:


  1. 创建你的表在目标服务器上使用脚本从脚本表As / Create脚本步骤


  2. 服务器,然后可以发出一个T-SQL语句:

      INSERT INTO dbo.YourTableNameHere 
    SELECT *
    FROM [SourceServer]。[SourceDatabase] .dbo.YourTableNameHere


这应该是正常的。


I have two SQL Servers (both 2005 version).

I want to migrate several tables from one to another.

I have tried:

  • On source server I have right clicked on the database, selected Tasks/Generate scripts. The problem is that under Table/View options there is no Script data option.

  • Then I used Script Table As/Create script to generate SQL files in order to create the tables on my destination server. But I still need all the data.

Then I tried using:

SELECT * 
INTO [destination server].[destination database].[dbo].[destination table] 
FROM [source server].[source database].[dbo].[source table]

But I get error :

Object contains more than the maximum number of prefixes. Maximum is 2.

Can someone please point me to the right solution to my problem?

解决方案

Try this:

  1. create your table on the target server using your scripts from the Script Table As / Create Script step

  2. on the target server, you can then issue a T-SQL statement:

    INSERT INTO dbo.YourTableNameHere
       SELECT *
       FROM [SourceServer].[SourceDatabase].dbo.YourTableNameHere
    

This should work just fine.

这篇关于将表数据从一个SQL Server导出到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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