日期:2014-05-18 浏览次数:20560 次
declare @table table (a int,b int,c int) insert into @table select null,null,1 union all select 1,null,1 union all select null,1,1 union all select 2,2,1 select * from @table /* a b c ----------- ----------- ----------- NULL NULL 1 --插入#t1和#t2 1 NULL 1 --插入#t2 NULL 1 1 --插入#t1 2 2 1 --不满足条件不要 */ --确认楼主是不是这个意思?
------解决方案--------------------
还是分开进行吧。
------解决方案--------------------
select * into #t1 from tb where C=1 and (B is null or A is null)
或者
select * into #t1 from
(
select * from tb where C=1 and B is null
union
select * from tb where C=1 and A is null
) as a