Wednesday 1 April 2015

How to find the IP address and Machine name of SQL Server ?

-- IP address and Machine name of SQL Server
SELECT Connectionproperty('local_net_address')       AS "IP Address",
       Serverproperty('ComputerNamePhysicalNetBIOS') "Machine Name"

-- Client and Server Ip Address and Mahine name
SELECT Serverproperty('ComputerNamePhysicalNetBIOS') "Machine Name",
       local_net_address                             AS "Server IP Address",
       client_net_address                            AS "Client IP Address"
FROM   SYS.DM_EXEC_CONNECTIONS
WHERE  SESSION_ID = @@SPID

No comments:

Post a Comment