SQL - QUERY TO GET SERVER'S IP ADDRESS

Jeet Verma

Total Post:110

Points:776
Posted by  Jeet Verma
 1266  View(s)
Ratings:
Rate this:
Hi All!

Is there a query in SQL Server 2005 I can use to get the server's IP or name?

Thanks in advance!
  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: SQL - Query to get server's IP address

    Hi Jeet!

    You can get server name as below

    SELECT @@SERVERNAME;

    IP Addresss or Name as below

    SELECT SERVERNAME = CONVERT(NVARCHAR(128),SERVERPROPERTY('SERVERNAME'))  
    ,LOCAL_NET_ADDRESS AS 'IPAddressOfSQLServer' 
    ,CLIENT_NET_ADDRESS AS 'ClientIPAddress' 
    --, NETBIOS = CONVERT(NVARCHAR(128),SERVERPROPERTY('COMPUTERNAMEPHYSICALNETBIOS'))  
    --, [MAXDOP] = (SELECT VALUE_IN_USE FROM SYS.CONFIGURATIONS WHERE NAME='MAX DEGREE OF PARALLELISM')   
    --, SQLMEMORY = (SELECT VALUE_IN_USE FROM SYS.CONFIGURATIONS WHERE NAME='MAX SERVER MEMORY (MB)')  
    --, EDITION = CONVERT(NVARCHAR(128),SERVERPROPERTY('EDITION'))  
    ---, COLLATION = CONVERT(NVARCHAR(128),SERVERPROPERTY('COLLATION'))  
    --, ISCLUSTERED = CONVERT(BIT,SERVERPROPERTY('ISCLUSTERED'))  
    --, ISFULLTEXTINSTALLED = CONVERT(BIT,SERVERPROPERTY('ISFULLTEXTINSTALLED'))  
    --, ISINTEGRATEDSECURITYONLY = CONVERT(BIT,SERVERPROPERTY('ISINTEGRATEDSECURITYONLY'))  
    --, FILESTREAMCONFIGUREDLEVEL = CONVERT(TINYINT,SERVERPROPERTY('FILESTREAMCONFIGUREDLEVEL'))  
    --, FILESTREAMEFFECTIVELEVEL = CONVERT(TINYINT,SERVERPROPERTY('FILESTREAMEFFECTIVELEVEL'))  
    --, PRODUCTVERSION = CONVERT(NVARCHAR(128),SERVERPROPERTY('PRODUCTVERSION'))  
    --, SQLCHARSETNAME = CONVERT(NVARCHAR(128),SERVERPROPERTY('SQLCHARSETNAME'))  
    --, SQLSORTORDERNAME = CONVERT(NVARCHAR(128),SERVERPROPERTY('SQLSORTORDERNAME')) 
     FROM SYS.DM_EXEC_CONNECTIONS WHERE SESSION_ID = @@SPID

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!