Is it possible to take a parameter that comes into a sproc that looks like
this:
'abc,xyx,ggg,ddd'
and put the elements which are separated by commas into an array?
Or is there any other method to take action on 'abc' and then 'xyx', and so
on.
Thanks,
don
sql 2000 or sql 7.0Hi,
There is no array concept in SQL Server. But there is an alternate way. See
the below URL:-
http://www.sommarskog.se/arrays-in-sql.html
Thanks
HAri
SQL Server MVP
"DonSQL2222" <DonSQL2222@.discussions.microsoft.com> wrote in message
news:259490C8-DABB-4C82-B963-E2B49C77C752@.microsoft.com...
> Is it possible to take a parameter that comes into a sproc that looks like
> this:
> 'abc,xyx,ggg,ddd'
> and put the elements which are separated by commas into an array?
> Or is there any other method to take action on 'abc' and then 'xyx', and
> so
> on.
> Thanks,
> don
> sql 2000 or sql 7.0
>|||> Is it possible to take a parameter that comes into a sproc that looks like
> this:
> 'abc,xyx,ggg,ddd'
> and put the elements which are separated by commas into an array?
SQL Server has absolutely no idea what you mean by array. But you can store
these values separately in a table, quite simply:
http://www.aspfaq.com/2248|||try
declare @.s varchar(1000), @.i int, @.val varchar(100)
select @.s = '123,456,789,000,'
select @.i = charindex(',', @.s, 1)
while @.i > 0
begin
select @.val = substring(@.s, 1, @.i - 1)
print @.val
select @.s = substring(@.s, @.i + 1, len(@.s))
select @.i = charindex(',', @.s, 1)
end
Rakesh
"DonSQL2222" wrote:
> Is it possible to take a parameter that comes into a sproc that looks like
> this:
> 'abc,xyx,ggg,ddd'
> and put the elements which are separated by commas into an array?
> Or is there any other method to take action on 'abc' and then 'xyx', and s
o
> on.
> Thanks,
> don
> sql 2000 or sql 7.0
>|||Thank you!! works perfectly. Just what i was looking for.
Don
"Rakesh" wrote:
> try
> declare @.s varchar(1000), @.i int, @.val varchar(100)
> select @.s = '123,456,789,000,'
> select @.i = charindex(',', @.s, 1)
> while @.i > 0
> begin
> select @.val = substring(@.s, 1, @.i - 1)
> print @.val
> select @.s = substring(@.s, @.i + 1, len(@.s))
> select @.i = charindex(',', @.s, 1)
> end
> Rakesh
> "DonSQL2222" wrote:
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment