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 2005 Forums
 Transact-SQL (2005)
 GetUser function?

Author  Topic 

Antinsh
Starting Member

16 Posts

Posted - 2008-03-19 : 08:34:36
What function returns name of the user that executes stored procedure?
The body of procedure is something like this:

UPDATE myTable
SET
data1=@data1
,data2=@data2
,userWhoDidThis=???
WHERE
id=@id

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-03-19 : 08:40:02
[code]UPDATE myTable
SET
data1=@data1
,data2=@data2
,userWhoDidThis=current_user
WHERE
id=@id[/code]

Edit: You can also use USER_NAME()

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -