Sql short circuit OR or conditional exists in where clause
问题 I'm trying to force sql server to make a short circuit OR comparison on some fields. On the left side of the Or I have a simple variable comparison and on the right side I have a pretty 'heavy' subquery. WHERE (@Var = 'DefaultValue' ) OR Exists(select * from atable) Is there any way to only execute the right side of the or statement if the first statement is false. I've tried case and if else statements but can't find any working syntax. I'm using a MS SQL server 回答1: You can't do what you