Since those ORs will force a table scan anyway, I'd suggest:Select ID, Name, State, Country From SearchDatabaseWhere ID = 101 AND Name = 'Jay' AND State = 'CA' AND Country = 'USA'set @rc = @@rowcountif @rc = 0begin Select ID, Name, State, Country From SearchDatabase Where Name = 'Jay' AND State = 'CA' AND Country = 'USA' set @rc = @@rowcountendif @rc = 0begin Select ID, Name, State, Country From SearchDatabase Where State = 'CA' AND Country = 'USA' set @rc = @@rowcountendif @rc = 0begin Select ID, Name, State, Country From SearchDatabase Where Country = 'USA'end
Be One with the OptimizerTG