March 1, 2012 at 11:57 am
Hello i have a query that i need help with.
The query has a filter
"where month= @month and customer = @customerr"
If i do not set the customer i need to get all the records of the month.
I know i can do an if and write the 2 queries, but i want to know if there is an option to avoid the "if"
Thank you
March 1, 2012 at 12:01 pm
I'd go with the IF statement.
March 1, 2012 at 12:24 pm
If you go with an IF, watch out for this:
http://sqlinthewild.co.za/index.php/2009/09/15/multiple-execution-paths/
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply