[英]SQL Server Select from multiple tables in array
Simple question about SQL Server 2808. 有关SQL Server 2808的简单问题。
View1: 视图1:
Select name from sys.tables where name like 'ab%'
Result: 结果:
Name
----
ab01
ab02
abxyz etc...
Now I want to query over those tables. 现在,我要查询这些表。
Select * from view1
Of course I get ab01, ab02, abxyz. 我当然会得到ab01,ab02,abxyz。 What I want is to query over the content
我想要的是查询内容
select * from ab01, ab02, abxyz
best of all would by to use union over the view1 query 最好的办法是在view1查询上使用union
Something like 就像是
Union view1
would be something like 会像
Select * from ab01
union
select * from ab02
....
any ideas? 有任何想法吗?
Greets 问候
Use a cursor. 使用光标。
Create a temporary table. 创建一个临时表。
Loop through the cursor and add the results to the temporary table. 循环游标并将结果添加到临时表中。
Select all from temporary table. 从临时表中全选。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.