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)
 Handling arrays in sproc w/o first splitting in to units

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-08-19 : 09:06:13
Mary writes "This problem has raised it's head a few times. Usually I solve it in ASP, but I think using SQL Server, being what is, there must be a workaround.
ASP code handles the addition of a TEST. Each test can have >=0 CHEMICALS. I retrieve them via ASP in a comma delimited string. Usually in the ASP I split this string and loop through the array :
1. Checking if this is a new chemical
2. Inserting it as new if not existing
3. Associating the test with the chemical in the bridge table

Is there a more efficient way of doing this using SQL Server functionality? A user defined function, perhaps?

1. You can't loop in SQL Server sproc?
2. You can't pass an array, can you?
3. If answer to 2 is no, how would split the comma delimited string in a sproc?

So basically I want to know can you handle arrays in SQL Server sproc?
And likewise can you split comma delimited strings?

thanks,
Mary"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-08-19 : 09:07:07
These will get you started:

http://www.sqlteam.com/SearchResults.asp?SearchTerms=csv

You can definitely pass the entire CSV to SQL Server and let it do all the work, it will be more efficient.

Go to Top of Page
   

- Advertisement -