Am planning to write an article under the topic "logged in user details" in sql server.
There are scenarios, where we need to find the logged in user. In that case, you can use the below sql builtin functions to identify the logged in users.
select host_name() Above command is used to find the logged in user in a network. Here Venkat is the host name. Machine connected to the sql server in the network.
If you want to find the user accessing the server, you can use the below command,
select suser_sname()In our example, suba is the user "logged in" into the server.
An alternative command to fetch the logged in user.
select system_user
There are scenarios where you want to find all the logged in user. Considering am having an issue like database deadlock or my resource utilisation is 100% and I need to check which resource is utilising more CPU. In that case,
sp_who command will be useful to identify the users details.
sp_who2 is an alternative command of sp_who. sp_who2 will provide you more options when compared to sp_who command.
Thanks and Regards,
Venkatesan Prabu .J
No comments:
Post a Comment