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)
 how to insert multiple values of same column type?

Author  Topic 

darenkov
Yak Posting Veteran

90 Posts

Posted - 2005-01-30 : 08:12:13
I have a table which allows the user to select multiple types of books that they are interested. the table has two fields:

TBL_BOOK_PREFS
---------------
book_id (fk)
user_id (fk)

At the moment I am using asp.net to loop through a checkboxlist and insert the values via a sproc. The only problem is that the sproc is in the loop, and therefore is called several times in succession, each time inserting the user_id and the book_id.

I was hoping there would be a more efficient way of doing this with SQL Server 2000. Is it possible to pass in the same user_id and respective book_id's via just the two input variables (@user_id, @book_id) in one proc?

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2005-01-30 : 08:56:03
There are a few options:

You can build a delimited string and parse it on the server via a udf or some other options
You can build xml and use SQL Servers OPENXML
You can use a dataset in asp.net

There may be other options.. I prefer the xml solution.
Go to Top of Page
   

- Advertisement -