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 2005 Forums
 Transact-SQL (2005)
 need help in procedure

Author  Topic 

chandru@zsl
Starting Member

8 Posts

Posted - 2008-04-01 : 10:49:41
hai all,
i have a issue i need your help on this ..
(i.e) I need to pass parameter like this 'one,two,three'.

I want output like

one
two
three

Thanks in advance

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2008-04-01 : 10:52:10
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648


"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2008-04-01 : 10:53:07
create proc a
@s varchar(1000)
as
;with csvtbl(i,j, s)
as
(
select i=1, s=charindex(',',@s+','),
substring(@s, 1, charindex(',',@s+',')-1)
union all
select i=j+1, j=charindex(',',@s+',',j+1),
substring(@s, j+1, charindex(',',@s+',',j+1)-(j+1))
from csvtbl where charindex(',',@s+',',j+1) <> 0
)
select s from csvtbl
go
exec a 'one,two,three'

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

chandru@zsl
Starting Member

8 Posts

Posted - 2008-04-01 : 11:04:31
Thanks for your kindly help..
Go to Top of Page
   

- Advertisement -