Use Comma Delimited String in Stored Procedure
Posted on 2004-10-26
I want to create a stored procedure to delete multiple records in a table. I'd rather not pass the where statement variables in one at a time, this will get cumbersome. Instead I would like to pass the values in a string or as an xml document.
I have two options. First I can loop through the comma delimited values and delete each item individually. Or I can create my Delete statement with a subquery that will extract the values from the XML document. This would get rid of the loop in the stored procedure but I didn't know what kind of performance I may lose by using a subquery.
My question is which of these two methods should I use? Can anyone think of a better way to accomplish this task?