Syntax: Recursion in SQL Server T-SQL.
•
ID: #99
Code
WITH RECURSIVE t(n) AS (
SELECT 1
UNION ALL
SELECT n+1 FROM t WHERE n < 6
)
SELECT * FROM t;
Notes
You can copy this snippet and adapt it. For advanced, add real-world inputs, edge cases, and tests.