Retreive Data from Remote SQL Server

Posted on 2011-05-11
Last Modified: 2012-05-11
Hi All,

We have a local SQL 2008 server and a remote SQL 2005 server at the other end of a VPN tunnel. We want to programatically retrieve data from the remote server. What is the best approach? Any experience is appreciated,
Question by:Primedius
    LVL 5

    Accepted Solution

    You may create a linked server on the local SQL 2008 server to reference the remote SQL 2005.
    LVL 11

    Assisted Solution

    While connected to the 2008 server, create a linked server to the 2005 machine:
    USE master;
    EXEC sp_addlinkedserver 
       N'SQL Server';

    Open in new window

    More info:

    Secondly you will need to add the login information you want to use to access the server from the remote 2008 machine (more than likely necessary):
    EXEC sp_addlinkedsrvlogin 'My2005Server', 'false', 'Domain\Mary', 'MaryP', 'd89q3w4u'

    Open in new window

    More info:

    Lastly, when you access your 2005 server you can use syntax like:
    SELECT * FROM My2005Server.DatabaseToUse.dbo.TableToUse;

    Open in new window

    LVL 21

    Expert Comment

    by:Alpesh Patel
    If in network then not an issue. but on different network then need to be on live ip and use it using link server
    LVL 25

    Expert Comment

    you can try openrowset too but linked server is better option.

    Author Closing Comment

    Thank you, This is what we did.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
    There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now