1. Please help support our sponsors by considering their products and services.
    Our sponsors enable us to maintain high-speed Internet connection and fast webservers.
    They support this free information and knowledge exchange forum service at no cost to you.

    Please welcome our latest sponsor Tectrade . We can show our appreciation by learning more about Tectrade Solutions

SQL query to return the servername

Discussion in 'Scripting' started by eRogue, Jun 19, 2013.

  1. eRogue

    eRogue ADSM.ORG Member

    Joined:
    Jul 21, 2008
    Messages:
    27
    Likes Received:
    0
    Occupation:
    Sys Admin
    Location:
    Toronto
    Does anyone knows how you can find out the servername using a select query ? I can't find any table containg it....
     
  2.  
  3. moon-buddy

    moon-buddy ADSM.ORG Moderator

    Joined:
    Aug 24, 2005
    Messages:
    6,866
    Likes Received:
    366
    Occupation:
    Electronics Engineer, Security Professional
    Location:
    Somewhere in the US
    select server_name from servers
     
  4. CoMaboy

    CoMaboy ADSM.ORG Senior Member

    Joined:
    Jun 4, 2012
    Messages:
    73
    Likes Received:
    11
    The status table contains the server name.
     
  5. eRogue

    eRogue ADSM.ORG Member

    Joined:
    Jul 21, 2008
    Messages:
    27
    Likes Received:
    0
    Occupation:
    Sys Admin
    Location:
    Toronto
    Thx moon-buddy, however, that will return all the servers that i have configured along with any lanfree clients. What i need is just the servername where the command is run...
     
  6. eRogue

    eRogue ADSM.ORG Member

    Joined:
    Jul 21, 2008
    Messages:
    27
    Likes Received:
    0
    Occupation:
    Sys Admin
    Location:
    Toronto
    That's the one!!! Thank you!
     
  7. jideck

    jideck ADSM.ORG Member

    Joined:
    Oct 10, 2006
    Messages:
    83
    Likes Received:
    0
    Occupation:
    Unix worker
    Location:
    Stockholm
    Actually
    >select server_name from status
    getting many lines because there is one status for every node so output will like
    tsm_inst1
    tsm_inst1
    tsm_inst1
    tsm_inst1
    tsm_inst1
    tsm_inst1
    tsm_inst1

    etc depending how many nodes are there ....
    so correct one is
    SELECT distinct(server_name) from status
    and answer will be

    SERVER_NAME
    ---------------------------------------------------------------------------------------------------------------------------------
    tsm_inst1
     
  8. jideck

    jideck ADSM.ORG Member

    Joined:
    Oct 10, 2006
    Messages:
    83
    Likes Received:
    0
    Occupation:
    Unix worker
    Location:
    Stockholm
    so useful query could be :
    Protect: TSM_INST1>SELECT distinct(status.SERVER_NAME),CAST(FLOAT(SUM(auditocc.BACKUP_MB))/1024/1024 as DEC (8,1)) as TB from STATUS,auditocc group by status.SERVER_NAME

    SERVER_NAME TB
    --------------------------------------------------------------------------------------------------------------------------------- -----------
    TSM_INST1 ---------------------------------------------- 5599.0
     
  9. marclant

    marclant ADSM.ORG Moderator

    Joined:
    Jun 16, 2006
    Messages:
    2,676
    Likes Received:
    374
    Occupation:
    Accelerated Value Specialist for Spectrum Protect
    Location:
    Canada
    This sounds odd. There should only be 1 row in the status table.

    Code:
    Protect: SERVER1>select count(*) from status
    
      Unnamed[1]
    ------------
               1
     

Share This Page