Hi All,
Table value function - StringAsIntTable function with one that uses CLR and regex performing slow. Any Alternative way can do better, Pls advice
Code:
CREATE function dbo.StringAsIntTable
( @values nvarchar(4000) )
returns @ret table (value int)
as
begin
declare @commaPos int
while datalength(@values) > 0
begin
set @commaPos = charindex(',', @values)
if @commaPos > 0
begin
insert @ret (value) values (cast(substring(@values, 1, @commaPos-1) as int))
set @values = substring(@values, @commaPos+1, 4000)
end
else
begin
insert @ret (value) values (cast(@values as int))
set @values = ''
end
end
return
end