Advertisement
yuvarajupadhyaya

cte recursion and insert

Aug 16th, 2022
1,844
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.22 KB | Source Code | 0 0
  1. WITH Sec(NUMBER) AS
  2. (
  3.     SELECT 16000 AS NUMBER
  4.    UNION ALL
  5.    SELECT NUMBER + 1
  6.     FROM Sec
  7.     WHERE NUMBER < 16200
  8. )
  9. INSERT INTO TestTable
  10. SELECT NUMBER FROM Sec
  11. OPTION(MAXRECURSION 0)
  12.  
  13. --select * from testtable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement