Multiple Select Statements using SQL Server 2005 “WITH” Statement

前端 未结 5 1496
清歌不尽
清歌不尽 2020-12-03 17:33

I am trying to use the \"WITH\" statement in SQL Server 2005. It seems to work fine if I do something like:

WITH MyBigProducts AS (SELECT * FROM Products WHE         


        
5条回答
  •  再見小時候
    2020-12-03 18:13

    CTE have statement local scope and visibility. If you want greater scope and visibility for a table expression, you would need to make the CTE into a View or table-valued function.

    Alternatively, you can materialize the expressions results into a table variable, which is local to the current batch or a temporary table whose lifetime is also local to the current batch, but whose visibility extends to the whole session.

提交回复
热议问题