Get Current User – Get Logged In User in sql server 2005

To get current user run following script in Query Editor
SELECT SYSTEM_USER
SYSTEM_USER will return current user. From Book On-Line – SYSTEM_USER returns the name of the currently executing context. If the EXECUTE AS statement has been used to switch context, SYSTEM_USER returns the name of the impersonated context.

Alternatively we can also use:
SELECT SUSER_SNAME()

No comments: