On Insert/Update get user name

I wish to add an Insert/Update trigger which will place in a Last Updated By column the current user.  My security is set up such that there are SQL Server log ins which are then assigned to dba created SQL Server roles which are given permissions to a database and its tables.  How do I go about doing this... I hope this makes sense.
ex. NT LAN id --> SQL Server login using NT authority --> login is assigned to a role --> role is given permissions on a database and specific permissions on a tables within the database.
kurtisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tchalkovCommented:
what exactly you want to do?
to make a column equal to the username who last modified the row?
0
StefaanCommented:
Hi,

If I'm not wrong the following select statement should return the current USER :

SELECT CURRENT_USER

If you want to use this in a stored procedure or trigger you could do something like :

DECLARE @Login CHAR(50)

SELECT @Login = CURRENT_USER

And then you can use @Login as a parameter to insert or update something.

You should also check USER_NAME, SESSION_USER, ... in the Books Online

Best regards,


Stefaan
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kurtisAuthor Commented:
Stefaan,
This is close, but not exactly what I need.  Basically I was hoping to get their NT LAN user id... is this possible?
0
StefaanCommented:
Hi,

Well, I thing you will have to do that in the client application, I don't think you can fetch that on the SQL Server.

Best regards,


Stefaan
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.