解决方法
您可以使用
recursive CTE在T-sql中生成任意数字序列,如下所示:
DECLARE @start INT = 1; DECLARE @end INT = 10; WITH numbers AS ( SELECT @start AS number UNION ALL SELECT number + 1 FROM numbers WHERE number < @end ) SELECT * FROM numbers OPTION (MAXRECURSION 0);