Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Determine the user who entered data Expand / Collapse
Author
Message
Posted Friday, November 1, 2013 7:19 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, November 18, 2015 5:40 AM
Points: 70, Visits: 267
I have been tasked to enable auditing on data entry in a SQL Server 2005 database. Specifically, I need to be able to determine what user entered data in a table and when. Can someone inform me as to what technique(s) is best suited for this need?
Than you.
Post #1510579
Posted Friday, November 1, 2013 7:26 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 4:31 PM
Points: 14,412, Visits: 37,701
well, you are only going to capture changes that occur in the future, after you've put some sort of auditing in place.
stuff that has already happened just plain is not captured...the transaction log might tell you WHEN some change was done, but it doesn't capture WHO did it.

for me, when it comes to row based auditing, a trigger on the table(s) in question is probably the first thing i'd look at.

some thing like this can get you the information about who/when insid ethe trigger itself, so you can save that information int he smae or different table:
  --the auditing snippet below works fine in a 
--login trigger,
--database trigger
--or any stored procedure.
SELECT
getdate() AS EventDate,
DB_NAME() AS DBName,
HOST_NAME() AS HostName,
APP_NAME() AS ApplicationName,
OBJECT_NAME(@@PROCID) AS ProcedureName,
USER_ID() AS Userid,
USER_NAME() AS UserName,
SUSER_ID() AS sUserid,
SUSER_SNAME() AS sUserName,
IS_SRVROLEMEMBER ('sysadmin') AS [Is_ServerAdmin_Sysadmin],
IS_MEMBER('db_owner') AS [Is_DB_owner],
IS_MEMBER('db_ddladmin') AS [Is_DDL_Admin],
IS_MEMBER('db_datareader') AS [Is_DB_Datareader],
ORIGINAL_LOGIN() AS [ORIGINAL_LOGIN]



Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
Post #1510581
Posted Monday, November 4, 2013 6:01 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, November 18, 2015 5:40 AM
Points: 70, Visits: 267
thank you Lowell for your quick response. I will attempt to implement your reply.
Post #1511071
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse