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
 Transact-SQL (2000)
 Arrays in Stored Procedure

Author  Topic 

Jeba_Antony
Starting Member

2 Posts

Posted - 2006-12-07 : 04:20:13
Hai,

I want to use a arrays in stored procedure.
i am using sql server 2005.
Till i didnt use any array concepts in sql.

what do i want is:
i have one variable
@pid='1,2,3,4,5,6,7'


I want to split this elements and store it into an array.


Please Advice.

Thanks........

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-07 : 04:23:58
Read this:

[url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=14932[/url]
[url]http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm[/url]

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2006-12-07 : 05:14:05
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-07 : 05:19:38
<<
I want to split this elements and store it into an array.
>>

Is that I want to split the numbers and get data from table?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-07 : 06:35:46
[code]declare @pid varchar(200)

select @pid = '1,22,333,4444,55555,666666,7777777'

SELECT SUBSTRING(',' + @pid + ',', number + 1, CHARINDEX(',', ',' + @pid + ',', number + 1) - number - 1)
from master..spt_values
where name is null
and number = CHARINDEX(',', ',' + @pid + ',', number )
and number < LEN(',' + @pid)
ORDER BY number[/code]

Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -