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/
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply