I have a View that grabs a lot of data that I want to be able to Search through. The View is set up with the following columns:
Part_Number, Description, Information, Supplier, Manufacturer, Category, Subcategory, Currency, Price, Discount.
I am looking to create a Stored Procedure which lets me search through the View for the data I am specifically looking for. Something like:
SELECT * FROM PartsData
WHERE Part_Number = '0010.05.20.20'
Now my first thought, was to set up the procedure so that the only parameter it was looking for was a VARCHAR
which would essentially contain whatever the entire WHERE
clause was. This sounds like it would work.
However, would I be able to instead set up a Stored Procedure with optional parameters? I am not sure if this is something you can do in SQL though.
If not, is my initial idea for implementation my best bet? Because it seems like there should be a better way to go about doing this. :\
Sometimes the WHERE
clauses can be rather long, such as:
WHERE Description LIKE '%cap'
AND Supplier LIKE 'A2A Systems'
AND Manufacturer LIKE 'Vario'