T-SQL Query to find IP Address of SQL Server | SansSQL

Saturday, March 23, 2013

T-SQL Query to find IP Address of SQL Server

Here is a handy T-SQL script to find the IP Address of the SQL Server you are connected to.

SELECT CONNECTIONPROPERTY('local_net_address') AS [IP Address Of SQL Server]

SELECT SERVERPROPERTY('ComputerNamePhysicalNetBIOS') [Machine Name]
   ,SERVERPROPERTY('InstanceName') AS [Instance Name]
   ,LOCAL_NET_ADDRESS AS [IP Address Of SQL Server]
   ,CLIENT_NET_ADDRESS AS [IP Address Of Client]
 FROM SYS.DM_EXEC_CONNECTIONS 
 WHERE SESSION_ID = @@SPID

16 comments:

Unknown said...

Thnx a lot.. god bless...

thongchai.jindatam said...

SELECT CLIENT_NET_ADDRESS AS [IP Address Of Client]
FROM SYS.DM_EXEC_CONNECTIONS
WHERE SESSION_ID = @@SPID


RESULT >>> local machine

Help Me plese

Sandesh Segu said...

You have to run this query from a remote PC to get IP address. If you are running from the same server as SQL server then the query returns Local Machine.

Unknown said...

Computer devices in the network configuration like PCs, printers, scanners and other machines are assigned with IP addresses. UK IP Restriction

SATEESH said...

i am unable to run this query in my sql, What are the permissions to perform this action.

Muhammad Hassan said...

Excellent website! I adore how it is easy on my eyes it is. I am questioning how I might be notified whenever a new post has been made. Looking for more new updates. Have a great day! 192.168

mark johnson said...

Much obliged to you again for all the learning you distribute,Good post. I was exceptionally intrigued by the article, it's entirely rousing I ought to concede. I like going by you site since I generally run over fascinating articles like this one.Great Job, I enormously acknowledge that.Do Keep sharing! Respects, check my ip address

markson said...

In the time of 2012 Gartner had anticipated that employment opportunities in Business Analytics and Data Scientist are surrendering to head toward somewhere in the range of Millions preceding 2015 attract to a nearbyData Analytics Course

vinith said...

Very Informative Article
Data Science Interview Questions

priyanka said...

I am looking for and I love to post a comment that "The content of your post is awesome" Great work!
data analytics course

dataexpert said...

This is exactly the information I'm looking for, I couldn't have asked for a simpler read with great tips like this... Thanks! ExcelR Data Analytics Courses In Pune

ek said...

Know more about Data Analytics
Cool stuff you have, and you keep overhaul every one of us.

priyanka said...

wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article resolved my all queries. keep it up.
data analytics course in Bangalore

priyanka said...

wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article resolved my all queries. keep it up.
data analytics course in Bangalore

priyanka said...

wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article resolved my all queries.
Data Science Course

priyanka said...

Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
Correlation vs Covariance
Simple linear regression

Post a Comment

Ads