在SQL Server中,如何在一个临时表中选择多个值?
例如,我想把'A‘,'B’放到#tmp表中,怎么做?
select 'A'
union
select 'B'
into #tmp发布于 2012-06-29 23:25:12
你需要把"Into“放在第一个select上,另外,如果你真的在做文字,那么你必须给它一个列名的标签。
Select 'A' As 'Label'
Into #tmp
Union
Select 'B'发布于 2012-06-29 23:23:53
将其包装为子查询(或CTE)
select * into #tmp
from
(
select col='A'
union select col='B'
) sub发布于 2012-06-29 23:22:58
insert #tmp (yourcol)
select 'A' union
select 'B'https://stackoverflow.com/questions/11264481
复制相似问题