How to get the client IP address from SQL Server 2008 itself? How to get the client IP address from SQL Server 2008 itself? asp.net asp.net

How to get the client IP address from SQL Server 2008 itself?


I found something which might work for you

CREATE FUNCTION [dbo].[GetCurrentIP] ()RETURNS varchar(255)ASBEGIN    DECLARE @IP_Address varchar(255);    SELECT @IP_Address = client_net_address    FROM sys.dm_exec_connections    WHERE Session_id = @@SPID;    Return @IP_Address;END

From How to get Client IP Address in SQL Server

Also have a look at this article about Get client IP address


You can try out this solution. It even works on shared hosting:

select CONNECTIONPROPERTY('client_net_address') AS client_net_address 


it needs just single line of code

 SELECT CONVERT(char(15), CONNECTIONPROPERTY('client_net_address'))