1

我试图将数据从一台服务器复制到另一台服务器。我的源服务器中已有链接服务器。当我尝试执行下面的查询时,出现错误。SQL Server 2012:使用链接服务器将数据从一个数据库服务器复制到其他数据库的表结构

SELECT Appt.C1 AS AppointmentId 
    ,Appt.C2 
INTO [190.28.111.187].[WH_AC].[dbo].[ApptDet] 
FROM [whse].[Vw_ApptDet] Appt 
INNER JOIN #DealerList DL ON DL.DealerId = Appt.DealerId 

错误:

Msg 117, Level 15, State 1, Line 4 
The object name '190.28.111.187.WH_AC.dbo.ApptDet' contains more than the maximum number of prefixes. The maximum is 2. 

我不知道我很想念那里。请建议我如何执行此操作。

回答

0

从上INTO clause文档:

You cannot create new_table on a remote server; however, you can populate new_table from a remote data source. [...]

所以,你一定要扭转你的声明(即从远程服务器上执行它),或做这是另一种方式。

0

You can retrive the data using this type of code style [190.28.111.187].[WH_AC].[dbo].[ApptDet]. in case of manipulation activity the SQL do not support. I would recommend to use openrowset to achieve this concept.

OPENROWSET('SQLNCLI', 'Server=YourServername;Trusted_Connection=yes;', 

To identify server name run the code

Select @@servername. 
0

我会为此使用集成服务(SSIS)。

0

如果你需要这样做(我下一步,这么好的问题)。

只需先创建表(在远程服务器上)

CREATE TABLE dbo.[TEST](
    [id] [int] NOT NULL, 
    [description] [varchar](50) NULL, 
    ) 

然后

insert into [server].[db].dbo.[TEST] 
select * from [TEST] 

我需要在这里我就不SA权利下周所以你将数据移动到链接服务器让我担心。我当然可以创建一个表,但不能建立远程的链接服务器。

相关问题