下面SQL 中的;with 为什么一定要加上':with'呢,起什么作用呢.
下面SQL 中的;with 为什么一定要加上':with'呢,起什么作用呢.
;with
digits (i) as(--set up a set of numbers from 0-9
select i
from (VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) as digits (i))
--builds a table from 0 to 99999
,sequence (i) as (
SELECT D1.i + (10*D2.i) + (100*D3.i) + (1000*D4.i) + (10000*D5.i)
FROM digits AS D1 CROSS JOIN digits AS D2 CROSS JOIN digits AS D3
CROSS JOIN digits AS D4 CROSS JOIN digits AS D5)
select i,nchar(i) as character
from sequence
where i between 48 and 122 --vary to include any characters
--in the character set of choice
order by nchar(i) collate Latin1_General_bin --change to the collation you
--are trying
GO
SQL 语句里面的 with是使用在 CTE 上面的CTE(Common Table Expression) ,即公用表表达式,可以认为是在单个 SELECT、INSERT、UPDATE、DELETE 或 CREATE ⅥEW 语句的执行范围内定义的临时结果集.CTE 与派生表类似,具体...