Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
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, July 2, 2014 9:19 AM
Points: 70, Visits: 265
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:51 AM
Points: 12,918, Visits: 32,085
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
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, July 2, 2014 9:19 AM
Points: 70, Visits: 265
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