I want to create a view in SQL as tableau software do not support CTE function. I'm Unable to add a view as I am using a MAXRECURSION. The error message is
Incorrect syntax near the keyword 'OPTION'.
Below is my existing CTE query using recursive.
Where and what do I need to add in my existing query?
WITH shiftHours AS (
-- This is a recursive CTE, code removed to improve readability
)
SELECT *
FROM (
SELECT * from shiftHours
) AS t
PIVOT (
SUM(hourValue)
FOR hourOrdinal IN ([0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20], [21], [22], [23])
) AS pvt
OPTION (MAXRECURSION 0)
GO