Get client IP address

Posted by Peter Larsson on SQL Team See other posts from SQL Team or by Peter Larsson
Published on Sat, 20 Mar 2010 19:48:42 GMT Indexed on 2010/03/20 21:11 UTC
Read the original article Hit count: 580

Filed under:
Up until now, I have used convuluted approaches to get the current user client IP-address.
This weekend I browsed Books Online for SQL Server 2008 R2 (November CTP) and found this new cool function!

SELECT  CONNECTIONPROPERTY('net_transport') AS net_transport,
        CONNECTIONPROPERTY('protocol_type') AS protocol_type,
        CONNECTIONPROPERTY('auth_scheme') AS auth_scheme,
        CONNECTIONPROPERTY('local_net_address') AS local_net_address,
        CONNECTIONPROPERTY('local_tcp_port') AS local_tcp_port,
        CONNECTIONPROPERTY('client_net_address') AS client_net_address

 //Peter

© SQL Team or respective owner