gpt4 book ai didi

sql-server-2008-r2 - 插入临时表而不从联合结果创建它

转载 作者:行者123 更新时间:2023-12-03 13:52:17 25 4
gpt4 key购买 nike

我有以下查询可以从多个选择中获取结果。
现在我希望这些在临时表中。

有没有办法在不创建表的情况下将这些插入到临时表中?

我知道如何为选择做到这一点

Select * into #s --like that

但是如何做到多选呢?
SELECT  Ori.[GeoBoundaryAssId],  Ori.[FromGeoBoundaryId], Ori.Sort 
From [GeoBoundaryAss] As Ori where Ori.[FromGeoBoundaryId] = (select distinct [FromGeoBoundaryId] from inserted )

Union

SELECT I.[GeoBoundaryAssId], I.[FromGeoBoundaryId], I.Sort
From [inserted] I ;

最佳答案

添加 INTO第一次后SELECT .

SELECT  Ori.[GeoBoundaryAssId],  Ori.[FromGeoBoundaryId], Ori.Sort 
INTO #s
From [GeoBoundaryAss] As Ori where Ori.[FromGeoBoundaryId] = (select distinct [FromGeoBoundaryId] from inserted )

Union

SELECT I.[GeoBoundaryAssId], I.[FromGeoBoundaryId], I.Sort
From [inserted] I ;

关于sql-server-2008-r2 - 插入临时表而不从联合结果创建它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17016741/

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