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)
 Inserting multiple values from CSV strings to SQL

Author  Topic 

tribune
Posting Yak Master

105 Posts

Posted - 2002-04-22 : 17:46:09
I have two strings with up to 120+ values separated by commas in each, and need to insert up to 120+ records into a basic sql table - one record for each index in both CSV's.

For example

string 1: "a,b,c,d,e"
string 2: "1,2,3,4,5"

and i need to insert into a table like:

a 1
b 2
c 3
d 4
e 5

So string 1 is the first column, and string 2 is the second column

I'd rather not do a loop through all 120+ values, but instead insert 'em all at once.......I was thinking about maybe using XML to do this but I dont really have a clue how to do it. Thanks for any advice.

-trib

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-04-22 : 18:29:37
This should do the job:

http://www.sqlteam.com/item.asp?ItemID=2652

Go to Top of Page

tribune
Posting Yak Master

105 Posts

Posted - 2002-04-22 : 21:39:25
lol a little more complicated than I was hoping but I got it to work, thanks :)

Go to Top of Page
   

- Advertisement -