Results 1 to 6 of 6

Thread: Possible to query another server?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2005
    Posts
    104

    Possible to query another server?

    Hi,

    I was wondering if it was possible to query another SQL server that is on the same network. For example, I have

    SQL1 - 192.168.1.50
    SQL2 - 192.168.1.51

    Can I query SQL1 from SQL2? If so, how? Thanks!

  2. #2
    Hyperactive Member vincentg's Avatar
    Join Date
    Jun 2005
    Location
    Chicago IL, USA
    Posts
    261

    Re: Possible to query another server?

    Hmmm i think so, as long you can provide two connections

    You mean....
    Query from the SQL Query Analyzer?
    from your application Program?

    Complicated one is to do an inner join on both.... but i think programmatically you can....


    Good luck!

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2005
    Posts
    104

    Re: Possible to query another server?

    Sorry, I'll try to elaborate a bit more.

    SQL1 - 192.168.1.50
    SQL2 - 192.168.1.51

    Using SQL1, I want to access data from SQL2. Here's the SQL statement I would use if I was in SQL2.

    Select * From Lot Where LotNum = 'XXX'

    I would find out what 'XXX' is from SQL1. I don't want to create another connection to connect to SQL2. Thoughts?

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Possible to query another server?

    What is the backend database?

    If this is MS SQL Server then you create a LINKED SERVER with ENTERPRISE MANAGER from SQL1 to SQL2 or the other way around.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2005
    Posts
    104

    Re: Possible to query another server?

    I think I was just failing to google the answer I needed. This is using MS SQL 2000. I was able to make a connection between the two by using

    <server name>.<database name>.<owner>.<table name>

    Hope that makes sense... thanks for the help everyone.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Nov 2005
    Posts
    104

    Re: Possible to query another server?

    szlamany:

    That's exactly the configuration that is in place now. I didn't know about linked servers until yesterday. Can you tell me if there is a reason why the connection would occasionally not work?

    Currently, SQL1 is the dataserver and SQL2 is a PDF server (I don't know why it's done this way... but it's been in place for more than a year now). I need to extract the PDF from the PDF server through the dataserver. But for some reason, I get this SQLOLEDB error. It doesn't tell me anything else (I'm retrieving it using a ASP.NET 2.0 website). Thoughts? Or am I on the wrong forum for this question?

    EDIT: I was trying to do the query in Enterprise Manager as well to see if it was a problem I had in the code. This is the error message I get from MS SQL.

    [Microsoft][ODBC SQL Server Driver][SQL Server][OLE/DB provider returned message: Unspecified Error]
    Last edited by Sedna; Aug 2nd, 2007 at 09:12 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width