sql server - Need to Create a SQL View from List of Tables -


trying create view tables have same fields different data in them. have table track each of these tables, , track ones active. want view tie active tables in 1 view.

say have tables a, b, , c. b , c active, table 1 lists each table , active. form table 1 can table names need view.

it escapes me on how on sql server (2008 version)

this sound bad design. better store data in 1 table , use partitioning methods access it.

here, though, 1 method want:

create view abc     select a.*     cross join          (select 1 table1 status = 'active' , tablename = 'a')     union     select b.*     b cross join          (select 1 table1 status = 'active' , tablename = 'b')     select c.*     c cross join          (select 1 table1 status = 'active' , tablename = 'c'); 

i don't recommend approach. intended show possible. chose cross join, because subquery evaluated once , might optimization underlying execution code.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -