简体   繁体   中英

How to use SQL VALUE substitution in Delete statement with WHERE clause

I'm trying to use VALUES substitution with a delete statement for SQL Server.

The following doesn't work, however. I'm at a little bit of a loss as to whether there is a straightforward way of making this happen.

What am I missing? Any help appreciated. Thanks.

DELETE
FROM [dbo].[Jobs_Current]
WHERE (jobNo = ? AND Name = ?)
VALUES (1234, 'Mr Ape')

I suspect you want this:

DELETE jc
    FROM [dbo].[Jobs_Current] jc JOIN
         (VALUES (1234, 'Mr Ape')) v(jobNo, name)
         ON jc.jobNo = v.jobNo AND jc.Name = v.Name;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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