I need to query multiple databases that contain the same structure and return the results into a single file. I can do it with a lot of work by using UNION ALL between each select statement and fully defined db names in the FROM but given that only the DB name is changing between each query it seems like a script would be better in case there are any changes (e.g. adding another field).
Note: DB's are all on the same server
Can anyone provide advice on how to best accomplish this?
Thanks in advance.