Are sql server transactions logged on a per user basis

Let's say I have a server that people log into. They then may access an instance of sql server 2008 on that server. Is there a way to tell who ran a certain stored procedure? Is it logged somewhere. User, what time etc>
Who is Participating?
It depends on your configuration as well as how users login. Are you using SQL based,logins, or windows authentication.
I.e. Auditing ....
If you use a common SQL login set within the application, then your tracking has to be amanged by the application given the SQL will see a single and the same SQL user as logging in.
Mohammed KhawajaManager - Infrastructure:  Information TechnologyCommented:
The answer to this question is it depends.  If your application is running as a service and your users authenticate against the application which may have its own security database the the answer is no every action is/could be recorded against the service account.  In situations such as this, the application provider usually provides/includes their own logging for auditing.

For details on SQL auditing, refer to for more info.
brgdotnetcontractorAuthor Commented:
All users when logging into the sql server use a generic username password. In other words they all use the same credentials to log in.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

How are the user's loging in, what is the application that they are using?
What is it they do on the SQL server if they login directly using SSMS or a similar tool?

Let's rephrase the, what is it you would like to record/maintain in terms of information dealing with the SQL server.
Presumably who logged in and when is not a sufficient set of data.
Presumably you want who logged in and whet they did is more of what you are looking for.
brgdotnetcontractorAuthor Commented:
I need to see who the last person was who ran a certain stored procedure. Not for a bad reason. I would just like to know if that is possible, and how to do it?
Single shared account you can not.  Making sure SQL logs logins you will at least know from where someone logged in. Who runs an sp is more difficult.  Adding record keeping to the sp I.e. When it was run will at least help you narrow the window.

Setting up an interface web based, through which users would need to login and trigger function is the only way other than reconfiguring the means of access to windows authentication and adjusting the rights.......
Not too difficult, but you could setup a windows group with a specific set of rights into which you will add the users.

The change they will make is to use integrated security /windows auth versus SQL logins.

With this, I believe the sp can record who ran it.
Vitor MontalvãoMSSQL Senior EngineerCommented:
You can capture a stored procedure by running a SQL trace. Then you'll have all the information you need such as SP name, execution date and time, origin of the request (user, computer and application).

Since SQL Server 2008 that you can use Extended Events in replacement of SQL traces since need less system resources.

Another option, more simple to implement and also better for the performance is to use SQL Audit.

You can find how to work with all these solutions in this excellent article.
Scott PletcherSenior DBACommented:
You can add code in the stored proc to log data from these functions:

Your own application will have to set the APP_NAME(); hopefully you can use it to provide the user's id/name.  HOST_NAME() should pick up the right value, but it can be "spoofed" (falsified) by explicitly specify a different value, so be aware if you have power users who might figure that out :-).
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.