Home > DeveloperSection > Forums > SQL - Query to get server's IP address
Jeet Verma
Jeet Verma

Total Post:110

Points:776
Posted on    April-16-2013 3:06 AM

 MSSQL Server MSSQL Server 
Ratings:


 1 Reply(s)
 971  View(s)
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!


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    April-16-2013 8:32 AM

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


Don't want to miss updates? Please click the below button!

Follow MindStick