mailtoashokberwal (4/25/2016)
Thanks 🙂I tried another approach with CTE and that works fine too.
WITH cte(a)
AS
(
SELECT 1
UNION ALL
SELECT a+1 FROM cte WHERE a<10000
)
SELECT * FROM cte OPTION(MAXRECURSION 10000)
That's going to be much, much slower. Jeff Moden wrote a great article about this technique. http://www.sqlservercentral.com/articles/T-SQL/74118/[/url]
-- Itzik Ben-Gan 2001