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)
 User Defined Function

Author  Topic 

Rita Bhatnagar
Posting Yak Master

172 Posts

Posted - 2001-06-26 : 09:12:26
Hello Gurus
Does anybody see some problem with this userdefined function.I am using it in more than 200 stored procedure so i want to be sure this is fine.Right now this works great.

CREATE FUNCTION Get_List( @array varchar(500) )
RETURNS @temp TABLE
(list_item int)

AS

BEGIN
declare @separator_position int
declare @array_value varchar(500)
select @separator_position= patindex('%,%',@array)
Set @Array =Stuff(@array,1,@separator_position,'')
While patindex('%,%',@array)<>0
Begin
select @separator_position= patindex('%,%',@array)
select @array_value = left(@array,@separator_position-1)
insert into @temp select @array_value
select @array=stuff(@array,1,@separator_position,'')
end
RETURN

END

   

- Advertisement -