withRecursiveCte method

MssqlQuery withRecursiveCte(
  1. String name, {
  2. required MssqlSelectQuery anchor,
  3. required MssqlSelectQuery recursive,
  4. required List<String> columns,
  5. int? maxRecursion,
})

Prefixes the query with a recursive expression.

anchor is the starting row set and recursive the member that selects from name itself. maxRecursion becomes OPTION (MAXRECURSION n); SQL Server's default is 100, and 0 removes the ceiling — which turns a cycle in the data from an error into a query that never returns, so pass it only where the data is known to be acyclic.

Implementation

MssqlQuery withRecursiveCte(
  String name, {
  required MssqlSelectQuery anchor,
  required MssqlSelectQuery recursive,
  required List<String> columns,
  int? maxRecursion,
}) => withExpression(
  MssqlCte.recursive(
    name,
    anchor: anchor,
    recursive: recursive,
    columns: columns,
  ),
  maxRecursion: maxRecursion,
);