No. It limits the number of times the Recursive definitions is called. You can play with this:
DECLARE @Geneology TABLE (
[personID] INT PRIMARY KEY
, [surname] VARCHAR(255)
, [firstname] VARCHAR(255)
, [parentID] INT
)
INSERT @Geneology ([personID], [surname], [firstname], [parentID])
SELECT 1, 'Smith', 'Fred', NULL -- Fred Smith
UNION SELECT 2, 'Smith', 'David', 1 -- David, Son of Fred
UNION SELECT 3, 'Smith', 'Judith', 2 -- Judith, Daughter of David
UNION SELECT 4, 'Jones', 'Mary', 3 -- Mary, Daughter of Judith
UNION SELECT 10, 'Brown', 'Harry' , NULL -- Harry Brown
UNION SELECT 11, 'Brown', 'Charles', 10 -- Charles, Son of Harry
-- Family Tree CTE (simplified)
; WITH family (
[personId]
, [Surname]
, [Firstname]
, [paternaty Path]
, [parentID]
, [level]
)
AS (
-- Anchor Definition (Gets the starts of all families where the parent is not known)
SELECT
[personID]
, [surname]
, [firstname]
, CAST([firstname] + ' ' + [surname] AS VARCHAR(MAX))
, [parentID]
, 1
FROM
@geneology
WHERE
[parentID] IS NULL
-- Recursive Definition
UNION ALL SELECT
g.[personID]
, g.[surname]
, g.[firstname]
, f.[paternaty Path] + ' -> ' + CAST(g.[firstname] + ' ' + g.[surname] AS VARCHAR(MAX))
, g.[parentID]
, f.[level] + 1
FROM
@geneology g
JOIN family f ON f.[personID] = g.[parentID]
)
SELECT * FROM family OPTION (MAXRECURSION 0)
This created a really simple recursive call to make up a simple family tree. Run it as it is and you'll get the complete picture. Start limiting the recursion and it will stop before it gets to all the generations.
If you still have questions feel free to ask.
Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION