Is it possible to do a select ( or insert) statement across different databases that are located on the same server? If yes, how?
It is possible to use SQL to write one query that combines the information from many databases. There are two requirements: You must prefix all table references with the database name (e.g. customers.
Open a new Query Window and write a query which has to be executed against multiple database of a server. Right click in the window and Select an option “Run On Multiple Targets” as shown below. This will open a new window which will have all the database available on the current server listed as shown below.
You would specify the database by using the syntax databasename.tablename
Example:
SELECT mydatabase1.tblUsers.UserID, mydatabse2.tblUsers.UserID FROM mydatabase1.tblUsers INNER JOIN mydatabase2.tblUsers ON mydatabase1.tblUsers.UserID = mydatabase2.tblUsers.UserID
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With