Ban*_*nny 7 sql-server insert linked-server
我有一台服务器SourceServer我连接到它有一个链接服务器TargetServer.
插入语句应该如何(我需要引用链接服务器,数据库,命名空间,表):
//Connected to [SourceServer]
USE [SourceDatabase]
DECLARE @HelloWorld NVARCHAR(255)
SELECT @HelloWorld = Name From dbo.Names where Id = 1
INSERT INTO [TargetServer].[TestDatabase].dbo.TestTable (Name) VALUES (@HelloWorld)
Run Code Online (Sandbox Code Playgroud)
此语句以异常执行:
Too many prefixes.
Run Code Online (Sandbox Code Playgroud)
更新:上面的语法工作正常,问题是用于连接到链接服务器的sql用户的密码过期:)
Con*_*eak 18
INSERT INTO [TargetServer].[TestDatabase].[dbo].TestTable (Name)
SELECT Name From [SourceServer].[SourceDatabase].[dbo].[Names] where Id = 1
Run Code Online (Sandbox Code Playgroud)