Advertisement
elena1234

RECURSION IN T-SQL

Mar 9th, 2022 (edited)
2,352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.23 KB | None | 0 0
  1. WITH DataSeries AS
  2. (
  3. SELECT CAST('01-01-2022' AS DATE) AS MyDate
  4.  
  5. UNION ALL
  6.  
  7. SELECT
  8. DATEADD(DAY,1,MyDate)
  9. FROM DataSeries
  10. WHERE MyDate < CAST('12-31 - 2022' AS DATE)
  11. )
  12.  
  13. SELECT
  14. MyDate
  15. FROM DataSeries
  16. OPTION(MAXRECURSION 365)
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement