Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Passing a comma delimited string to a stored procedure to insert values into a unity table.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-10-06 : 01:09:05
Ken writes "Dear Worshipful Masters of SQL,

I'm working with a registration form that will allow visitors to enter their name and contact information to be placed on a mailing list. This is an ASP form that sends data to an SQL 7.0 database. When the user registers, he is assigned a unique identity-seeded id.

Check boxes have been placed on the form to allow visitors to be added to more than one mailing list. Using VBScript, the checkbox names are parsed on the ASP to create a comma delimited list. Like so:

for each objItem in Request.Form
if left(objItem,4) = "art_" then
if Request(objItem) = "on" then
strBody = strBody & mid(objItem,5) & ","
end if
end if
next

This returns a comma delimited string (item1,item2,item3, etc). I want to send this string to a stored procedure (as @strBody) and then insert each item into a unity table with the user's id.

The unity table is defined as:
Column Name - Data Type - Allow Nulls
user_id - integer - yes
item_id - integer - yes

One option I considered was looping on the ASP and inserting each record one at a time, inside the loop. I know that will work. However, I would rather place the processing burden on the SQL side, rather than on the ASP side. How can I do this with SQL?"
   

- Advertisement -