Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Use Comma Delimited String in Stored Procedure

Posted on 2004-10-26
Medium Priority
Last Modified: 2006-11-17
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?
Question by:INFINIEDGE
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

SashP earned 200 total points
ID: 12411321
Insert the record key values into a table.  Call the stored proc to process the values out of the table as the items to delete.

This way you can still encapsulate all of the logic you need in the stored proc but you don't have the limitations of passing a composite field to the stored proc.

Otherwise go with the XML Doc parameter its not that involved.  Try to avoid the comma seperated field if you can.

If you have to go with the comma seperated field populate all of the values into a table in memory before executing the delete statements, you don't want to execute 100s of individual delete statements when you can execute 1.

Cheers Sash

Author Comment

ID: 12411574
Thanks for the quick response.

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question