Search code examples
sql-serverdatabase

How to get user details from SQL Server session like user ip,host name etc


I want to get user all possible details from SQL Server session like user ip, host name etc. I have searched about sp_who. Any expert can guide me how I can achieve this? I have searched a lot but not found master piece


Solution

  • may be i exactly don't know what you are expecting

    but this may help you

    Try this

    SELECT *
    FROM sys.sysprocesses 
    WHERE spid = @@SPID
    

    in this we can find username,host etc..;