Users Information

-- SQL Server 2000
-- Users Information
-- Depending on the connection string, the nt_domain and the nt_username may not be populated.

SELECT USER 'USER'
     , USER_NAME() 'USER_NAME()'
     , SESSION_USER 'SESSION_USER'
     , CURRENT_USER 'CURRENT_USER'
     , SYSTEM_USER 'SYSTEM_USER'
     , HOST_ID() 'HOST_ID()'
     , HOST_NAME() 'HOST_NAME()'

SELECT hostname
     , program_name
     , nt_domain
     , nt_username
     , loginame 
    FROM master.dbo.sysprocesses 
    WHERE spid = @@SPID

-- query NT user name
SELECT RIGHT(SYSTEM_USER, LEN(SYSTEM_USER) - CHARINDEX('\', SYSTEM_USER))
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s