I have 2 queries that are essentially the same (at least if I didn’t miss something). I was thinking that one cannot beat constants declared in the query itself, but apparently the first query is few times slower than the second one. It seems that SQL server is not smart enough to provide a good plan for the hardcoded values,
Tag: where-in
SQL use CASE statement in WHERE IN clause
Is it posible to use case in where in clause? Something like this: DECLARE @Status VARCHAR(50); SET @Status=’published’; SELECT * FROM Product P WHERE P.Status IN (CASE WHEN @Status=’…