I have a many to many relation between a table product and a table order, the link table is ProductInOrder.
I want to make a stored procedure with a list of product ids as inputs and what it would do is create a new order and add a new record to the link table for each product.
I have now achieved this using a client initiated transaction, then calling a sp to create a new order, then a loop in the client to call a sp to create each record in the link table.
But there must be a way to do this in sql.
Any ideas?
Best
What you want is something like this (for MSSQL, at least):
Pass
@Productsin as a comma-delimited string of integers, e.g.-'1,2,3,15,100'.To load up a temp table in C#, you’d do this (using a
SqlCommandnamedcomm):