Easy way

  • hi,

    I have a code like this

    declare @server

    decare @counterid

    set @server =...

    select Max(mem) ,avg(Mem) from counter where server = @server and counter =@counterid

    I have to check some counter inforamtion for 10 servers ..,

    So what im doing is for every server Im declaring a variable and setting the server name to that variable..

    Im repeating the above process 10 times because we have 10 servers and executing 10 times.But i want to execute 1 time and have to get results for 10 servers

    Can anyone suggest me the easy way to do this

  • Do you have "linked servers" setup on one server to access all the other servers? If not, and I have to ask, do you have the login information for all 10 servers so you can make a remote query to each?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

  • We have all the inforamtion about the servers in reporting server.

    I have to write queries on reporting servers and I have full access to reporting server.

  • Forgive my ignorance... does that mean that the reporting server has "linked servers" to all the other servers or does that mean all the data from the other servers is in separate databases on the reporting server? It will make a bit of a difference in how we attack this problem.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

  • Or is the data in one table in a database on the reporting server?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

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

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