?
Solved

On Insert/Update get user name

Posted on 1999-11-09
4
Medium Priority
?
264 Views
Last Modified: 2008-03-10
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.
0
Comment
Question by:kurtis
  • 2
4 Comments
 
LVL 7

Expert Comment

by:tchalkov
ID: 2196136
what exactly you want to do?
to make a column equal to the username who last modified the row?
0
 
LVL 3

Accepted Solution

by:
Stefaan earned 400 total points
ID: 2196167
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
 

Author Comment

by:kurtis
ID: 2203803
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
 
LVL 3

Expert Comment

by:Stefaan
ID: 2206193
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

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question