1

我正在尝试将来自一台服务器上的一个数据库的信息插入到另一台服务器上的表中而不插入重复项,我得到标题错误。这是代码

INSERT INTO [Datamaxx].[dbo].[data_job_t] (JobCode, Description) 
SELECT job_no, description
FROM OPENDATASOURCE('SQLNCLI',
'Data Source=server\server;Integrated Security=SSPI')
.cas_tekworks.dbo.jobs WHERE Job_Status ='A' and data_job_t.JobCode  not in (select Jobcode from [Datamaxx].[dbo].[data_job_t])
4

1 回答 1

1

你试过这个吗......

job_no 不是在而不是 data_job_t.JobCode

INSERT INTO [Datamaxx].[dbo].[data_job_t] (JobCode, Description) 
SELECT job_no, description
FROM OPENDATASOURCE('SQLNCLI',
'Data Source=server\server;Integrated Security=SSPI')
.cas_tekworks.dbo.jobs WHERE Job_Status ='A' and job_no not in (select Jobcode from [Datamaxx].[dbo].[data_job_t])
于 2013-09-27T17:17:09.107 回答