|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, December 14, 2009 10:50 AM
Points: 2,
Visits: 10
|
|
sunil,
You can use this style too....
set @Gender = isNull('M', '_') set @Age = isNull(22, 0)
SELECT * FROM test_EmployeeDetails Where Gender LIKE @Gender AND Age > @Age
Thanks! Azeem
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Thursday, November 15, 2012 9:55 PM
Points: 226,
Visits: 114
|
|
| this does not help if you have nullable fields
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 4:07 PM
Points: 1,943,
Visits: 8,227
|
|
Interesting.....
I can now get multiple index seeks 
drop proc test2 go create proc test2 @ProductId integer, @ReferenceOrderID integer, @Quantity integer as
select * from [Production].[TransactionHistory] where (@productid is not null and @productid = ProductID) or (@ReferenceOrderID is not null and @ReferenceOrderID = ReferenceOrderID) --or (@quantity is not null and @quantity = Quantity) Uncomment This to force a scan go
exec test2 @productid = 790,@ReferenceOrderID = NULL,@Quantity=NULL go exec test2 @productid = NULL,@ReferenceOrderID =61197 ,@Quantity=NULL
It seems to seek if ALL the referenced columns are indexed, but uncommenting the Quantity lookup a scan takes place.
Edit : Ive updated my blog http://sqlandthelike.blogspot.com/ with this info
Clear Sky SQL My Blog Kent user group
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, December 14, 2009 10:50 AM
Points: 2,
Visits: 10
|
|
| isNull funcation for nullable value ... try then reply
|
|
|
|