anakaine
anakaine

Reputation: 1248

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')

Upvotes: 0

Views: 67

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269693

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;

Upvotes: 2

Related Questions