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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

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.

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
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.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook 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 :-).
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.