Union from 2 different databases

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
767
Office Version
  1. 365
Platform
  1. Windows
Good morning,

I am reasonably new to SQL and I have written a simple union query to pull data from 4 tables in 1 database as per below.

But is there anyway I can do a union from 2 different databases as they each hold different months data.
I understand how to do this in VBA where I would use a source file etc.. but I haven't attempted this in SQL, all the columns etc.. will be the same as I am going from a weekly basis to a monthly

I currently refresh this data via going PowerPivot, Design - Table Properties and SAVE.
This is where I would update everything going forward as well.

Code:
SELECT week_20_51.field1, 20_51.field2, 20_51.field3
FROM 20_51
UNION ALL SELECT 20_52.field1, 20_52.field2, week_20_52.field3
FROM week_20_52

thanks in advance
Gavin
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,214,599
Messages
6,120,453
Members
448,967
Latest member
grijken

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top