需要从本地人员表中删除记录,该记录终止了远程雇员表中的雇员状态。尝试执行以下操作,但无法正确打开查询语法:
DELETE FROM PERSON WHERE ID IN
OPENQUERY(LSVR1,'SELECT DISTINCT ID FROM EMPLOYEE WHERE EMPLOYEE_STATUS=''T'' AND TERMINATION_DATE<SYSDATE-365')
我知道
“关键字'openquery'附近的语法不正确。”
答案 0 :(得分:0)
您可以使用IN (SELECT ... FROM OPENQUERY() alias)
:
DELETE FROM PERSON WHERE ID IN (
SELECT ID
FROM OPENQUERY(LSVR1,
'SELECT DISTINCT ID FROM EMPLOYEE WHERE EMPLOYEE_STATUS=''T'' AND TERMINATION_DATE<SYSDATE-365'
) sub);