how to get user's IP Address in sql?

  • hi all.

    we want to log changing data such as isert,delete and update that users perform.we can do this.but now we want to khnow

    which user do this changes?I want to get user's IP Address for this purpose,how to get user's IP Address in sql?

  • AFAIK there is no @@connectionIPaddress, but you can use this DMV to get this info

    Select client_net_address

    from sys.dm_exec_connections

    where session_id = @@spid

    A regular user (=non sysadmin) by default only gets to see data of his current spid on this DMV, unless being granted "view systemstate" (don't just do that!).

    Because every system has sysadmins, who get to see all data rows of this dmv, include the mentioned where clause in your code;

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • elham_azizi_62 (10/25/2010)


    hi all.

    we want to log changing data such as isert,delete and update that users perform.we can do this.but now we want to khnow

    which user do this changes?I want to get user's IP Address for this purpose,how to get user's IP Address in sql?

    Duplicate posthttp://www.sqlservercentral.com/Forums/Topic1010535-391-1.aspx

    Please don't post the same question in many places.

    Thanks

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply