Consider the following SQL (SQL Server 2008) statement:
WITH MyResult AS
(
SELECT
Name,
Row_ID AS ORD
FROM Person Where Gender = @Gender
)
SELECT *
FROM MyResult
WHERE ORD > 5
Is MyResult stored in a temporary table in the tempdb? Or does it do something else?
We are optimising some queries and would lke to better understand WITH statements (internally) to help gauge performance etc.
Thanks