从一台服务器复制 Table 并插入另一台服务器:这个 T-SQL 查询有什么问题?

Copy Table from a Server and Insert into another Server: What is wrong with this T-SQL query?

我正在使用 SQL Server 2014。我创建了以下 T-SQL 查询,我每天在特定时间将其上传到本地 SQL 服务器到 运行 作为作业流程。但是,我注意到它未能 运行。如果我在 SSMS 中手动 运行 它,它 运行 是正确的。 是什么阻止了对 运行 的查询作为一个自动化过程?是语法问题吗?

USE MyDatabase
GO

DELETE FROM ExchangeRate -- STEP 1

;WITH MAINQUERY_CTE AS ( --STEP 2
    SELECT *
    FROM (
        SELECT *
        FROM [178.25.0.20].HMS_ARL.dbo.ExchangeRate
    ) q

)
INSERT INTO ExchangeRate --STEP 3
SELECT *
FROM MAINQUERY_CTE

基本上,查询的功能是从实时服务器复制一个名为ExchangeRate的table并将其内容粘贴到一个同名的table(已经存在)在我的本地服务器上)。

错误日志显示以下消息:

Description: Executing the query "USE MyDatabase DELETE FROM ExchangeRate..." failed with the following error: "Access to the remote server is denied because no login-mapping exists.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. End Error DTExec: The package execution returned DTSER_FAILURE (1). Started: 10:59:30 AM Finished: 10:59:30 AM Elapsed: 0.422 seconds. The package execution failed. NOTE: The step was retried the requested number of times (3) without succeeding. The step failed.

可能您必须在本地服务器中创建到远程服务器的链接服务器?