December 15, 2021 at 3:13 pm
Hi
I have below parameters .
@frDate date,
@toDate date,
@VName nvarchar(100) = null,
@CName nvarchar(100) = null,
I want if user has entered nothing in VName and Cname then
where should be between @frDate and @ Todate
If user has entered Vname & Dates then
all records with date range and Vname = @ Vname and all CName records like so on
Thanks
December 15, 2021 at 3:43 pm
IF <test>
BEGIN
SELECT... FROM...WHERE... <params>
END
ELSE
SELECT...FROM WHERE <different params>
There's nothing stopping you from forking the two queries with an IF statement.
December 15, 2021 at 4:04 pm
It's beginning to look a lot like ... a catch-all query.
I suggest you get yourself a nice drink and read this article: https://sqlinthewild.co.za/index.php/2018/03/13/revisiting-catch-all-queries/
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy