Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 869869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:22:43+00:00 2026-05-15T10:22:43+00:00

Consider the following SQL (SQL Server 2008) statement: WITH MyResult AS ( SELECT Name,

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:22:43+00:00Added an answer on May 15, 2026 at 10:22 am

    No, as per this MSDN article

    …the CTE is a language-level
    construct—meaning that SQL Server does
    not internally create temp or virtual
    tables…

    And also, as mentioned here:

    A common table expression (CTE) can be
    thought of as a temporary result set
    that is defined within the execution
    scope of a single SELECT, INSERT,
    UPDATE, DELETE, or CREATE VIEW
    statement. A CTE is similar to a
    derived table in that it is not stored
    as an object and lasts only for the
    duration of the query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following SQL Server 2005/2008 query: Select [UID], [DESC] From SomeTable Order By
Consider the following SQL statement: SELECT invoice.customer_name, invoice.customer_id, invoice.shop_location, sum(invoice.cost) FROM invoice GROUP BY
Please consider the following SQL Server table and stored procedure. create table customers(cusnum int,
Can i apply SUM() within an ISNULL() .... Consider my following sql server select
Consider the following SQL: SELECT mov FROM movie WHERE mov IN ( SELECT mov
Consider the following table in SQL Server 2008: LanguageCode varchar(10) Language nvarchar(50) LanguageCode participates
Consider the following sql server query , DECLARE @Table TABLE( Wages FLOAT ) INSERT
Consider the following 3 standard statements $queryString = SOME SQL SELECT QUERY; $queryResult =
Consider the following queries. select * from contact where firstname like '%some%' select *
In SQL Server 2008, consider the table create table myTable (id int, filler char(X))

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.