In my application I have a form that has some filter fields. None are required, if the user does enter a value I need to provide those as parameters in a where clause.
I don't know how to handle this in my stored procedure though.
for example the following stored procedure:
--parameters
@customername varchar(50),
SELECT * from ORDERS
WHERE customername = @customername
so if the user enters a Customername then of course it will return all with that customer name, if the user does not enter a user name it needs to return everything. How can I do this in this statement? is there a wildcard I can pass if the user didn't enter a customer name? Or do I need a separate procedure. I hope that makes sense, thanks!