gpt4 book ai didi

SQL Server WITH 语句

转载 作者:行者123 更新时间:2023-12-04 13:16:08 25 4
gpt4 key购买 nike

我的目标是从一个 CTE 中选择结果,并在同一过程中用另一个 CTE 插入到另一个表中。怎么做?

我的错误是...

invalid object name xy.



我的查询是
WITH ds
(
Select a, b, c
from test1
),
xy
(
select d, e, f
from test2
where (uses conditions from ds)
)
Select *
from ds (the result set of ds, am exporting this to csv)

Insert into AuditTest
(
Select * from xy
)

最佳答案

CTE 仅适用于一个查询,但您似乎可以在每个查询中使用 CTE:

WITH ds AS
(
Select a, b, c from test1
)
Select * from ds (the result set of ds, am exporting this to csv)


WITH xy AS
(
select d,e,f from test2 where (uses conditions from test1)
)
Insert into AuditTest
(
Select * from xy
)

关于SQL Server WITH 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28725389/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com