OPTION (maxrecursion 0)Explanation of Jingyang's solution:Step 1: Create a numbers table based on the string length but it would be better to use an auxiliary numbers table; Step 2: Cross join Numbers table to create positions and steps for all substring combinations; Step 3: C...
INSERT#ineachdb(id,name)SELECTd.database_id,d.nameFROMsys.databasesASdWHEREEXISTS(SELECT1FROMnamesWHEREname=d.name)OPTION(MAXRECURSION0);ENDELSEBEGININSERT#ineachdbSELECTdatabase_id,nameFROMsys.databases;END-- first, let's delete any that have been explicitly excludedIF@exclude_list>N...
FROM T OPTION(MAXRECURSION 2) --Note:注意控制最大递归数
[Id] ) SELECT * FROM [CTE] ORDER BY [CTE].[Id] OPTION ( MAXRECURSION 0 ) ; 电流输出 代码语言:javascript 复制 Id Value Parent_Id ValuePath 1 A NULL A 2 B 1 B 2 B 1 A > B 3 C 2 B > C 3 C 2 A > B > C 3 C 2 C 4 D 1 D 4 D 1 A > D 5 E NULL E 6 F...
SELECT i FROM CTE_NumbersTable OPTION (MAXRECURSION 0) RETURN; END Code You can use this recursive t-sql user defined function to create an auxilary SQL Server database table which has a sequence of numbers. If you want to build a dates table again using a recursive function in SQL Server...
OPTION (maxrecursion 0) Explanation of Jingyang's solution: Step 1: Create a numbers table based on the string length but it would be better to use an auxiliary numbers table; Step 2: Cross join Numbers table to create positions and steps for all substring combinations; Step 3...