我发现用视图还有不便之处,我用了联接查询
declare @t1 table
(
id1 int,
name1 char(10),
type char(10)
)
declare @t2 table
(
id2 int,
name2 char(10)
)
insert into @t1 values('1','syee','hi')
insert into @t1 values('2','heble','hey')
insert into @t2 values('1','小张')
insert into @t2 values('2','小李')
select name1 as name from @t1
union
select name2 as name from @t2
还可以再建立一个虚拟表
declare @t1 table
(
id1 int,
name1 char(10),
type char(10)
)
declare @t2 table
(
id2 int,
name2 char(10)
)
insert into @t1 values('1','syee','hi')
insert into @t1 values('2','heble','hey')
insert into @t2 values('1','小张')
insert into @t2 values('2','小李')
declare @t3 table
(
id3 int,
name char(10)
)
insert into @t3
select id1,name1 from @t1
insert into @t3
select id2,name2 from @t2
select name from @t3
以上两种方法均测试通过。
name
--------
heble
syee
小李
小张