CREATE TABLE #temp0([Name] varchar)
CREATE TABLE #temp1([Name] varchar)
CREATE TABLE #temp2([Name] varchar)
-----------------------------------------
删掉 用 select..into 表名 时 ,要求该表是不存在的!
select [Name] into #temp0 from Table where 条件1;
这句中的#temp0 ,你不用在前面单独创建。若存在该表 SQL语句就出错
CREATE TABLE #temp1([Name] varchar)
CREATE TABLE #temp2([Name] varchar)
-----------------------------------------
删掉 用 select..into 表名 时 ,要求该表是不存在的!
select [Name] into #temp0 from Table where 条件1;
这句中的#temp0 ,你不用在前面单独创建。若存在该表 SQL语句就出错
CREATE TABLE #temp1([Name] varchar)
CREATE TABLE #temp2([Name] varchar)insert into #temp0 select [Name] from Table where 条件1;
insert into #temp1 select [Name] from Table where 条件2;
insert into #temp2 select temp0.Name from #temp0,#temp1 where #temp0.Name=#temp1.Name select @Count1=count(*) from #temp0
select @Count2=count(*) from #temp1
select @Count3=count(*) from #temp2
select [Name] into #temp1 from Table where 条件2;
select temp0.Name into #temp2 from #temp0,#temp1 where #temp0.Name=#temp1.Name
select @Count1=count(*) from #temp0
select @Count2=count(*) from #temp1
select @Count3=count(*) from #temp2
sum(case when b.[Name] is null then 0 else 1 end) as Count2,
sum(case when (a.[Name] is null or b.[Name] is null) then 0 else 1 end) as Count3
from (select [Name]
from Table
where 条件1
) a
full join
(select [Name]
from Table
where 条件2
) b
on a.[name]=b.[name]