If OBJECT_ID('GetList','IF') Is Not Null Drop Function GetList Go Create Function Dbo.GetList() Returns Table as Return ( Select 1 Number,'CHOPL' IntegerFromList Union Select 2,'NAKRL' Union Select 3,'NLGD2' Union Select 4,'DEVKD' Union Select 5,'HALYA' ) Go
Select * from dbo.GetList() Go
Cheers www.SQLServerbuddy.blogspot.com iLink Multitech Solutions
Create PROCEDURE asp_splitstrings (@string varchar(50)) AS DECLARE @id integer = 1, @previous_id integer = 0, @value varchar(50) create table #temp (Number int Identity(1,1), IntegerFromList varchar(50)) WHILE @id > 0 BEGIN SET @id = CHARINDEX(',',@string,@previous_id+1) IF @id > 0 BEGIN SET @value = SUBSTRING(@string,@previous_id+1,@id-@previous_id-1) INSERT INTO #temp VALUES (@value) SET @previous_id = @id END END IF @previous_id < LEN(@string) BEGIN SET @value = SUBSTRING(@string,@previous_id+1,LEN(@string)) INSERT INTO #temp VALUES (@value) END select * from #temp
exec asp_splitstrings 'CHOPL,NAKRL,NLGD2,DEVKD,HALYA'
SRILATHA .Net Developer
Login to post response