Results 1 to 3 of 3

Thread: How to Get user LoginID from T-SQL

  1. #1
    Join Date
    Oct 2003
    Posts
    8

    How to Get user LoginID from T-SQL

    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

  2. #2
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    --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

  3. #3
    Join Date
    Mar 2003
    Location
    Woking, UK
    Posts
    152
    /* 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()
    You Have To Be Happy With What You Have To Be Happy With (KC)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •