System User Name

  • Hi,

    We have different function within the SQL to get the usrename in SQL. but do we have any function to get the Windows NTUser name in SQL server 2005.

    I want to get the system i.e. Windows Login User in SQL server 2005?

    Thanks & Regards,

    Abhijit

    ( Database Developer )

  • [font="Verdana"]Hi,

    I was not clear.. Do you need the list of logins exists in windows user panel or do you need to windows user name connected to SQL Server?[/font]

  • Thats true i want to know the Windows NT Users (log on name) whoare connected to SQL server we got the machine name from HOST_NAME() functions, but I wan the logon name for that particular host.

  • select SPID,

    DB_NAME(dbid) as dbname,

    dbid,

    hostname,

    program_name,

    loginame from master.dbo.sysprocesses

    Order by login_time desc

    Or use xp_logininfo 'DOMAIN\USER'

    or use xp_logininfo 'DOMAIN\groupname','members' - this will list all the members of the NT group.

  • Hi,

    Just use sp_who2.

    If you need more info just cutomize sp_who2 for your needs

    Regards

  • We get the details using xp_logininfo, sp_who2.. i think i need to explain you the scenario a little bit more...

    Okay.. I have Server say 100.100.100.2

    Different developers are accessing the server. now my question is how can we see who are accessing the Server.. ( their m/c Login Name )

    e.g 10 developers a re in XYZ domain but their NT login is Different.. I'll get their machine name like X1, X2, X3, X4... but i wan to knwo there NT user Name like in X1-XYZ1 is logged in, in X2-XYZ2 is logged in.

  • select * from sys.dm_exec_requests

    select * from sys.dm_exec_connections

    Select * from sys.dm_exec_sessions

    These should be your best bet on SQL Server 2005. These DMV's Provide more info than sysprocesses and sp_who2.

    Join them to your needs.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply