sql-server - 使用select语句将数据插入临时表?
问题描述
我想从 select 语句中手动将数据插入到临时表中:
Select into #temp from (select 1,2
Union
select 2,4
Union
Select 8,12) as b
解决方案
您需要为列命名(这里我已命名列a
和b
):
Select a, b into #temp
from
(
select a = 1, b = 2
Union
select 2, 4
Union
Select 8, 12
) as t
select * from #temp
a b
-----
1 2
2 4
8 12
只有 a 的第一个SELECT
子句UNION
需要明确的列名。
推荐阅读
- python-3.x - Python数学问题
- jquery - 将 div 动画到另一个 div 的位置并在调整屏幕大小时跟随它?
- kubernetes - Minikube 无法启动 -> pgrep kube-api
- python - 如何删除熊猫中的nan值?
- java - JDBC COUNT() 某行如何得到结果
- java - java - 银行系统 - 将 arraylist 从 main 传递到 JFrame Table
- php - 如何插入具有相同名称的多个选择输入
- python - Windows 上带有队列的子进程 stdout.PIPE 流的非阻塞线程仍然挂起
- c# - Azure function 2.x ILogger 与 .net core ILogger 不兼容?
- c - 在 C 中分析指针和指针到指针结构的技巧?