-
-
Save anonymous/e74858c05d1ba97b11bb561437c45542 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
create function dbo.GetRows(@ID int) | |
returns @T table | |
( | |
ID int, | |
D datetime | |
) with schemabinding as | |
begin | |
declare @N int; | |
-- Time passes | |
with C as | |
( | |
select 1 as N | |
union all | |
select C.N + 1 | |
from C | |
where C.N < 50000 | |
) | |
select @N = count(*) | |
from C | |
option (maxrecursion 0); | |
insert into @T(ID, D) values(@ID, getdate()); | |
return; | |
end; | |
go | |
select R.ID, R.D | |
from (values(1),(1),(2),(2)) as T(ID) | |
cross apply dbo.GetRows(T.ID) as R |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment