I'm trying to create some generic stored procedures that can be used for multiple outputs.
The key table is quite simple - it's a sales invoice line table with date, sales rep, customer, product code, quantity, price and some other fields. It has ~1million records
I'm trying to work out the most efficient way of filtering by product and or customer code or codes which are passed in on a single variable.
Variables passed in should match the beginning of the field they're filtering on.
ie Product code is 8 digits eg:
11123456 or 11145678 or 11256789 or 11251112 or 11312345
pass in 111 in a product code variable and it should match 11123456 and 11145678 - but I want to be able to pass in 111 and 112 and have it match all except the code starting 113
Similarly with the customer code.
I'm contemplating doing it with a split function - as I can...