Selecting rows from same name table from multiple databases in single result set For some reason, I have a table Table_1 in n databases (same name and schema structure) instead of one single databases. The columns are like this:


  | Column_1 | Column_2 |


I can select data from those n databases by running this query on each of them:

use Database_n
select * from Table_1


Problem: This will require me to run this query n times. Which will return n result sets as shown in the below image:



Question: Is there a way to get the data from all those databases in one single result set like this:
Sure :

    select * from database_n.dbo.Table_1
    UNION ALL
    select * from database_n+1.dbo.Table_1
    UNION ALL
    select * from database_n+2.dbo.Table_1
    -- etc.