简体   繁体   English

SP中关键字“删除”附近的语法错误不正确

[英]Error incorrect syntax near keyword 'Delete' in SP

My SP is throwing error where I am trying to delete some entries from the tables. 我的SP抛出错误,我试图从表中删除一些条目。 To be in safe side I got IF EXISTS and under it I have the delete statement but I am getting this error 为了安全起见,我得到了IF EXISTS并在其下有delete语句,但出现此错误

Incorrect syntax near the keyword 'DELETE'.

Delete stmt 删除stmt

IF EXISTS (DELETE FROM myTable WHERE id IN ((SELECT ids FROM @tranId)));

I am not sure if the syntax is incorrect. 我不确定语法是否不正确。

The IF is unnecessary, as are the extra parentheses: IF是不必要的,多余的括号也是:

DELETE FROM ESG.DOCUMENT_SET_TRANS_MDATA
    WHERE DOCUMENT_SET_TRANS_MDATA.DOCUMENT_SET_TRANSACTION_ID IN (SELECT ids FROM @tranId);

DELETE FROM ESG.DOCUMENT_TRANSACTION
    WHERE DOCUMENT_TRANSACTION.DOCUMENT_SET_TRANSACTION_ID IN (SELECT ids FROM @tranId);

DELETE FROM ESG.DOCUMENT_SET_TRANSACTION
    WHERE DOCUMENT_SET_TRANSACTION.DOCUMENT_SET_TRANSACTION_ID IN (SELECT ids FROM @tranId);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM