Which result will be returned?

You need to determine the result of executing this code segment.
DECLARE @RangeStart INT = 0;
DECLARE @RangeEnd INT = 10000;
DECLARE @RangeStep INT = 1;

WITH NumberRange(ItemValue)
AS (
SELECT ItemValue
FROM (SELECT @RangeStart AS ItemValue) AS t
UNION ALL
SELECT ItemValue + @RangeStep
FROM NumberRange
WHERE ItemValue < @RangeEnd)

SELECT ItemValue
FROM NumberRange
OPTION (MAXRECURSION 100)

Which result will be returned?

You need to determine the result of executing this code segment.
DECLARE @RangeStart INT = 0;
DECLARE @RangeEnd INT = 10000;
DECLARE @RangeStep INT = 1;

WITH NumberRange(ItemValue)
AS (
SELECT ItemValue
FROM (SELECT @RangeStart AS ItemValue) AS t
UNION ALL
SELECT ItemValue + @RangeStep
FROM NumberRange
WHERE ItemValue < @RangeEnd)

SELECT ItemValue
FROM NumberRange
OPTION (MAXRECURSION 100)

Which result will be returned?

A.
101 rows will be returned with no error.

B.
10,001 rows will be returned with no error.

C.
101 rows will be returned with a maximum recursion error.

D.
10,001 rows will be returned with a maximum recursion error.



Leave a Reply 0

Your email address will not be published. Required fields are marked *