четверг, 23 августа 2012 г.

MS SQL 2008: Client IP address on shared hosting


Task:
get IP-address of the client (IP-address of client connection)
(for example to write to the log address of the computer you are using to connect)


Surroundings and limitations:
MS SQL 2008 database is on a hosting without admin rights.
There are no rights to execute dm_exec_connections.

Solution
(key line highlighted)

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 

Links

MSDN help

1 комментарий: