Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Performance Issue with Table Valued Function

$
0
0

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

Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>