Is it posible to use case in where in clause? Something like this:
DECLARE @Status VARCHAR(50);
SET @Status=\'published\';
SELECT * FRO
maybe you can try this way
SELECT *
FROM Product P
WHERE (CASE
WHEN @Status = 'published' THEN
(CASE
WHEN P.Status IN (1, 3) THEN
'TRUE'
ELSE
FALSE
END)
WHEN @Status = 'standby' THEN
(CASE
WHEN P.Status IN (2, 5, 9, 6) THEN
'TRUE'
ELSE
'FALSE'
END)
WHEN @Status = 'deleted' THEN
(CASE
WHEN P.Status IN (4, 5, 8, 10) THEN
'TRUE'
ELSE
'FALSE'
END)
ELSE
(CASE
WHEN P.Status IN (1, 3) THEN
'TRUE'
ELSE
'FALSE'
END)
END) = 'TRUE'
In this way if @Status = 'published', the query will check if P.Status is among 1 or 3, it will return TRUE else 'FALSE'. This will be matched with TRUE at the end
Hope it helps.