Exactly.
It's a use it or lose it scenario.
WITH CTE AS (
SELECT 'a' AS a
)
SELECT 'b'
SELECT *
FROM CTE
Gives an error "Common table expression defined by not used".
WITH CTE AS (
SELECT 'a' AS a
)
SELECT *
FROM CTE
SELECT *
FROM CTE
The first select works, but the second gives the error "Invalid object name 'CTE'".
Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.
No comments:
Post a Comment