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)
 using graz' sp_ParseArray

Author  Topic 

PeterG
Posting Yak Master

156 Posts

Posted - 2002-05-09 : 15:11:24
How do I modify his stored proc so I just get, say, the 2nd member of the array instead of looping through the array? I only want my stored procedure to process the array member corresponding to a number I pass to the stored proc?

PeterG
Posting Yak Master

156 Posts

Posted - 2002-05-09 : 16:36:14
here's his code:
http://www.sqlteam.com/downloads/sp_parsearray.sql

Go to Top of Page

nizmaylo
Constraint Violating Yak Guru

258 Posts

Posted - 2002-05-09 : 18:53:46
This means you would have to create an array. An array for SQL Server is a temp table, which represents an array. It should have two columns.
CREATE TABLE #myArray(
subscript int,
value yourdatatype)

You'll still have to loop. First, you have to loop thru your comma delimited string and instead of processing the data store it your temp table. After that you could jump to a value in the array based on the subscript requested.

helena
Go to Top of Page

M.E.
Aged Yak Warrior

539 Posts

Posted - 2002-05-10 : 11:19:26
If you just want the second (or 3rd or whatever one) through in another @var that increments everytime the loop goes through (right before the end for the loop, put a @var=@var+1) where graz has

select Array_Value = @array_value

add beneath it

if @var = 2 Break

The keyword break will end the while loop so it doesn't continue through.

Do remember to declare the @var int as well as set @var = 1 before the loop begins.

Help any?

Go to Top of Page
   

- Advertisement -