sql select on multiple db's -


i got around 18 db's. these db's have same structure. want query these db's once results.

example:

shopa shopb shopc

these db's got table article (and same rows). how articles in 1 result where?

i thought:

select * shopa.dbo.article      shopb.dbo.article      shopc.dbo.article color = 'red' 

did got idea?

have considered doing union all?

so like:

select      'a' shop, *         shopa.dbo.article        color = 'red'  union  select      'b' shop, *         shopb.dbo.article        color = 'red'  union  select      'c' shop, *         shopc.dbo.article        color = 'red' 

or, cte (if rdbms supports it)

;with allstores (     select      'a' shop, *             shopa.dbo.article      union      select      'b' shop, *             shopb.dbo.article      union      select      'c' shop, *             shopc.dbo.article ) select      *         allstores        color = 'red' 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

qt - How to embed QML toolbar and menubar into QMainWindow -