# Miscellaneous > Ask an Expert >  How to Get user LoginID from T-SQL

## geossl

Dear All,
  Using select user_name() always return dbo. But I wanted the loginID. 

  How to get the user's LoginID using T-SQL?

  Thanks

----------


## MAK

--list all logins from a server

select name,loginname from master.dbo.syslogins

--list all logins connected to sql server.

you have to query sysprocesses table and syslogins and join. check BOL

----------


## YuckFou

/* information about the current user */

--server level (login)
select system_user , suser_sname() , suser_sid() 
--db level (db user)
select session_user , current_user , user , user_name() , user_id()

----------

