라이프로그


How to get Client IP Address in SQL Server 2005/2008 DB창고

 

While executing some query, sometimes it is required to have the Client's IP Address who is executing this Query.

SELECT client_net_addressFROM sys.dm_exec_connectionsWHERE session_id = @@SPID;

We can also put this Query into some function which can be used further.
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
http://arsalantamiz.blogspot.com/2008/06/how-to-get-client-ip-address-in-sql.html

덧글

댓글 입력 영역