We have a system which builds T-SQL queries from objects. This system deliberately throws exception if trying to use empty lists for IN() condition.
I am thinking of replacing this behaviour with IN (NULL) operation.
From what I tried, this returns no rows, even for values which are null.
This is ideal behavior for my situation.
But in MS documentation, there is this remark:
Any null values returned by subquery or expression that are compared to test_expression using IN or NOT IN return UNKNOWN. Using null values in together with IN or NOT IN can produce unexpected results.
Can IN (NULL) be used to consistently return no rows? Is this considered a bad practice?