Here is a very simple CTE:
;
WITH test
AS
(
SELECT GETDATE() AS CurrentDate
)
SELECT * FROM test
SELECT * FROM test
Why can't I select twice on the CTE table? The second select statement returns an error:
*(1 row(s) affected)
Msg 208, Level 16, State 1, Line 9
Invalid object name 'test'.*