[thelist] Stored procedure

Anthony Baratta Anthony at Baratta.com
Tue Jan 28 00:17:01 CST 2003


At 09:56 PM 1/27/2003, Stevenson Ngila wrote:
>I have two strings i.e. string1 = "peter,john,steve" and string2=
>"mary,jane,janet".
>
>(1)i want to loop through string1 and string2 and get "peter" from string1
>and "mary" from string2 and insert both name in to a table.
>(2) I want to repeat the above procedure and get "john" and "jane" and
>insert them in to a table.
>
>Can someone please assist me with the stored procedure to do these in SQL
>server 2000!

I think you are better off parsing the strings with ASP (assuming you are
using ASP) then inserting the matched pairs into the DB.

e.g.

     aryOne = Split(string1,",")
     aryTwo = Split(string2,",")

     for x = 0 to (UBound(aryOne)-1)
         strQuery = "INSERT INTO Table1 (CoupleNameOne,CoupleNameTwo)" & _
                 "VALUES('" & aryOne(x) & "','" & aryTwo(x) & "')"
     next

Of course this assumes that the two strings have the same number of elements.
---
Anthony Baratta
President
Keyboard Jockeys

"Conformity is the refuge of the unimaginative."




More information about the thelist mailing list