We currently have a stored procedure with a few parameters and one of them is a list of invoice numbers that is comma separated.
The stored procedure creates a temp table, uses a local function to split out the invoice numbers, populate the temp table and uses the data in the temp table to select data from another table.
I would like to modify this stored procedure to add another parameters to control the sort order of the data. It appears I will need to use sp_executeSQL to get this to happen. I am not sure how to do this for the portion to create, populate the temp table and to
use the data in the temp table in my select statement.
Attached is the original SP and the changes I have tried
Thanks in advance for your help,
tsharp