Created
April 25, 2019 19:44
-
-
Save mburbea/ed0c6210bb9aaf245911b7570b0b74d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @i varchar(max)='1'+replicate(',1',3999),@d datetime2 = sysdatetime(),@_ int | |
--slow | |
select @_=i.value('.','int') | |
from ( | |
select a=convert(xml,'<i>'+replace(@i,',','</i><i>')+'</i>') | |
) a | |
cross apply a.nodes('./i') x(i) | |
select datediff(ms,@d,sysdatetime()); | |
select @d=sysdatetime(); | |
--fast | |
select @_=i.value('.','int') | |
from ( | |
select a=lag(convert(xml,'<i>'+replace(@i,',','</i><i>')+'</i>'),0) over (order by (select 1)) | |
) a | |
cross apply a.nodes('./i') x(i) | |
select datediff(ms,@d,sysdatetime()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment