日期:2014-05-17 浏览次数:20735 次
if object_id('[TB1]') is not null drop table [TB1]
go
create table [TB1] (A1 int,A2 int,A3 int,A4 int)
insert into [TB1]
select 22,33,44,55
if object_id('[TB2]') is not null drop table [TB2]
go
create table [TB2] (A1 int,A2 int,A3 int,B4 int)
insert into [TB2]
select 66,77,88,99 union all
select 22,33,44,88 union all
select 99,28,36,17
if object_id('[TB3]') is not null drop table [TB3]
go
create table [TB3] (A1 int,A2 int,A3 int,C4 int)
insert into [TB3]
select 66,77,88,23 union all
select 22,33,44,81 union all
select 55,99,51,37
select * from [TB1]
select * from [TB2]
select * from [TB3]
;WITH    TT
          AS ( SELECT   A1 ,
                        A2 ,
                        A3
               FROM     dbo.TB1
               UNION
               SELECT   A1 ,
         &n