Advertisement

Latest Post

Monday, 8 May 2017

Find Hostname and Current Logged In User Name


 Sql server provided build in function HOST_NAME () and SUSER_NAME ()

Most of developer and DBA, want to know the Hostname and Current Logged In User Name. Sql server provided build in function HOST_NAME () and SUSER_NAME () to return the Hostname and Current Logged In User Name.

Here is the example of HOST_NAME() and SUSER_NAME()


-- Logged in using SQL Authentication
SELECT HOST_NAME() AS HostName, SUSER_NAME() LoggedInUser

OutPut:-

HostName
LoggedInUser
LENOVO-09
sa

Government Jobs