22,206
社区成员
发帖
与我相关
我的任务
分享
create view v_TableSource
as
select Source='表1',ID from 表1
union all
select Source='表2',ID from 表2
union all
select ...............
调用
SELECT Source FROM v_TableSource WHERE ID=@ID--传参变量
select * from
(select datasource='t1',* from [表1]
union all
select datasource='t2',* from [表2]
union all
select datasource='t3',* from [表3]
union all
select datasource='t4',* from [表4]
union all
select datasource='t5',* from [表5]
union all
select datasource='t6',* from [表6]
union all
select datasource='t7',* from [表7]
union all
select datasource='t8',* from [表8]) t
where t.ID=[待查ID]