I have run across some situations when programming where I wish I could pass an “array” into a SQL stored procedure. What I mean by “array” is a string that is delimited by a certain character (i.e., string1;string2;string3). The reason as to why I like having this ability is because when I’m programming I do not want to have a loop inside one of my data classes executing multiple SQL statements. I would rather have the multiple SQL statements be taken care of on the stored procedure side of things. Lucky for me one of our authors, Q , came up with SQL code that will iterate a string.

Let me provide an example of the situation you could use this in.

tbl_Requests -> holds basic information about a request. The column names are below

intRequestID strRequestName strRequestor dtRequested blAdditionalInfo

The blAdditionalInfo column is a flag saying there are an unknown amount of miscellaneous details that go along with this request that are not standard.

tbl_RequestsMiscItems - > holds miscellaneous items / details

intMiscItemID intRequestID strItemName

Now that we have two simple tables to help out, lets say I am filling out a request and fill in the basic information, however, as a programmer you don’t know how many misc. items there may be related to the request…hence the separate table for it. Instead of my code handling making separate calls to SQL or executing multiple statements inside my code to insert the additional items, I can just store all of the misc. items into a string delimited by a character. For example when they submit the form my values may look like this: