SELECT * FROM Missions WHERE
(
(@Division IS NULL OR ( @Division IS NOT NULL AND Division = @Division)) AND
(@Lieu IS NULL OR (@Lieu IS NOT NULL AND Lieu = @Lieu)) AND
(@Date1 IS NULL OR (@Date1 IS NOT NULL AND Date1>= @Date1)) AND
(@Date2 IS NULL OR (@Date2 IS NOT NULL AND Date2 <= @Date2))
)
Case you pass the value 'NULL' in your variables @Division and @Lieu disconsider my changes.
I hope this help.
Kindly mark this post as "Answer", if it helped you.
pierrefrc
Participant
947 Points
201 Posts
Re: SQL Statement error
May 02, 2012 11:01 AM|LINK
HI
Try change to:
Case you pass the value 'NULL' in your variables @Division and @Lieu disconsider my changes.I hope this help.