Popular Posts
-
Rules of Coding The most important language you will ever code in: English (or the common spoken language used in your company). -- So...
-
Here is how to parse a date that is in the format of mm/dd/yyyy: // Parse string with date but no time component. string dateStr...
-
Tonight I attended a conference hosted by The Church of Jesus Christ of Latter-day Saints. It's topic was the protection of the institu...
-
View the complete solution at https://github.com/adamvaul/React-Server-Side-Web-Forms . I love ReactJS.Net. It is a framework for manag...
Wednesday, February 2, 2011
Connecting Two Remote Databases in a single SQL Query
Background
Every Microsoft SQL Server database, there is a folder called Server Objects. Within that folder there is a folder called "Linked Servers". If you right click on that folder and hit New Linked Server, it will open up a new linked server wizard.
New Linked Server Wizard
By following the steps there, you can setup a new linked server.
First, type in the name or IP address of the server where it says "Linked server". For example: "1.0.9.46".
For a remote SQL database choose SQL Server as the server type. Then select the security page from the left, and enter the login credentials under the "Be made using this security context" option: Enter the username where it says remote login, and the password below where it says "With password."
Creating a Query using the Linked server.
Once your linked server is setup, you can execute a query like the following:
SELECT *
FROM
[1.0.9.46].DatabaseName.dbo.tableName t
JOIN users ON user.ID = t.userID;
Enjoy!!!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment