Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Capture Username in SQL

Author  Topic 

Brittney10
Posting Yak Master

154 Posts

Posted - 2011-05-09 : 14:26:51
Is there a way to capture a username in SQL and write it to a record. I want to be able to tell who updated or added a record in a field called "modified_by." Are there any built-in objects i can pull to get this?

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-05-09 : 14:38:00
try system_user

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-05-09 : 14:38:34
Take your pick:


CURRENT_USER
SESSION_USER
SYSTEM_USER
USER_NAME()
SUSER_SNAME()
ORIGINAL_LOGIN()

All these functions are documented in Books Online, you should read up on them to decide which is best for you.
Go to Top of Page
   

- Advertisement -