sql 使用union出現問題 select a,b,c into #tb from table union select a,b,c into #tb2 from table2union前後的語句都可以單獨運行,但是加上union一起的話就報錯;錯誤提示:SELECT INTO must be the first query in a statement containing a UNION, INTERSECT or EXCEPT operator. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select a,b,c into #tb from table select a,b,c into #tb2 from table2select * from #tbunionselect * from #tb2 select a,b,c into #tb from table 是创建表并且插入数据,并不是查询结果而union 是取那个结果集的并集 ,所以不能这样写 謝謝您的回答但這樣會報錯:The ntext data type cannot be selected as DISTINCT because it is not comparable。謝謝。 select a,b,c into #tb from table select a,b,c into #tb2 from table2select * from #tbunion all --不过滤重复数据了select * from #tb2 不能带着into 进行 union。 SQL保留一条数据,然后相邻数据相减 sql2000中存储图片 执行"select name from Table"把第行name字段的值用“,”隔开变成一个字符串,不用存储过程能不能做到? 请问高手:修复数据库的问题 在线求...sql server 重装后dts包找回问题 如何取得一个时间段的每个月 查询合并记录 sqlserver2000,我设置主键字段了,但是怎么我用存储过程竟然能插入空值呢? 高分求一个Sql SERVER查询语句 如何删除表中当前行的记录? SQL 取并集与交集 【求助】WIN7旗舰版64位安装SQL Server2005出现的兼容问题
select a,b,c into #tb from table
select a,b,c into #tb2 from table2select * from #tb
union
select * from #tb2
謝謝您的回答但這樣會報錯:The ntext data type cannot be selected as DISTINCT because it is not comparable。謝謝。
select a,b,c into #tb from table
select a,b,c into #tb2 from table2select * from #tb
union all --不过滤重复数据了
select * from #tb2