How can i query the two servers and different databases reports in a single statement.

  • Dear Experts,

    Here i have a sceneraio like (Client request), i have to provide the query which has to result from two different servers and with two different databases in a single query statement.

    Example : AGCNUSA - server ; AGUSA - DB

    and AGCNUK - Server ; AGUK - DB these are two different servers located in two different networks.

    As a pure DBA Usually i used to provide the errors count individually for two different servers. But my client asked me to provide the sigle query rather than running two different queries for error counts.

    Can anyone please help me how can this be made for convinient.

    ------------------------------------------------------------------------

    My Query :

    select Tech_Mod,Tech_Mess ,count(*) from EForms4_Errors where

    error_user in (select userid from AGUSA.dbo.users where roles like '%ag%') and

    error_date between '2009-04-07 00:00:00 AM' and '2009-04-07 23:59:59 PM'

    group by Tech_Mess,Tech_Mod

    order by 3 DESC

    ------------------------------------------------------------------------

    Thanks,

    CH&HU.

    Cheers,
    - Win
    "Dont Judge a Book by its Cover"

  • HI,

    try using the linked server. u can get the result.

    🙂

  • Linked server created already and there we are facing connectivity issues.

    Can anyone provide the query which retrieve the data from two servers on different databases at a time.

    Any idea if linking the sever throegh query itself.

    Cheers,
    - Win
    "Dont Judge a Book by its Cover"

  • You can also consider Adhoc queries. For basic information visit my blog post http://blog.dbdigger.com/2008/09/accessing-remote-data-source-linked.html

    DBDigger Microsoft Data Platform Consultancy.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply