Anyone know what this will return?
create function RecursiveTest(@V int)
returns @t table (i int)
set @v = @v - 1
insert into @t
select @v union
select * from dbo.RecursiveTest(@v)
insert into @t values (0)
select * from dbo.RecursiveTest(10)
Try it out!
Unfortunately, the argument must be less than or equal to 32 due to the number of levels of recursion SQL can handle. It's probably not very efficient, either. But, it's pretty cool!