@@ -7,12 +7,12 @@ Last Updated: 07/05/2022
77This script is written in SQL Server's T-SQL
88
99
10- • Determining permutations can be performed with a recursive CTE; this solution uses a WHILE loop
11- • This solution uses an initial numbers table (#Numbers) that must be populated
12- • The #Permutations table is initially seeded from the #Numbers table
13- • The #Numbers table could be eliminated and simply just seed the #Permutations table
14- • To keep the record count manageable, a DELETE is performed on the #Permutations within the WHILE loop
15- • Output is saved in the temporary table #Permutations
10+ • Determining permutations can be performed with a recursive CTE; this solution uses a WHILE loop
11+ • This solution uses an initial numbers table (#Numbers) that must be populated
12+ • The #Permutations table is initially seeded from the #Numbers table
13+ • The #Numbers table could be eliminated and simply just seed the #Permutations table
14+ • To keep the record count manageable, a DELETE is performed on the #Permutations within the WHILE loop
15+ • Output is saved in the temporary table #Permutations
1616
1717**********************************************************************/
1818
@@ -31,18 +31,18 @@ DECLARE @vTotalNumbers BIGINT = 3;
3131-- -------------------
3232-- -------------------
3333-- Create a #Numbers table using recursion
34- WITH cte_Factorial (Number )
34+ WITH cte_Numbers (Number )
3535AS (
3636 SELECT 1 AS Number
3737 UNION ALL
3838 SELECT Number + 1
39- FROM cte_Factorial
39+ FROM cte_Numbers
4040 WHERE Number < @vTotalNumbers
4141)
4242SELECT
4343 Number
4444INTO #Numbers
45- FROM cte_Factorial
45+ FROM cte_Numbers
4646OPTION (MAXRECURSION 0 );-- A value of 0 means no limit to the recursion level
4747
4848-- -------------------
0 commit comments