2 Replies - 6056 Views - Last Post: 09 October 2010 - 04:23 AM

#1 hemiras  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 24-April 07

Find who deleted the record in the table of sql server 2008

Posted 09 October 2010 - 12:57 AM

How can I find who deleted the record in the table in SQL Server 2008?
Is This A Good Question/Topic? 0
  • +

Replies To: Find who deleted the record in the table of sql server 2008

#2 Ionut  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 385
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: Find who deleted the record in the table of sql server 2008

Posted 09 October 2010 - 02:13 AM

I don't think MSSQL can (or wants) to store this information, but you can create a trigger on the table.
So, create a table MyTableHistory with the same structure as MyTable
 
CREATE TRIGGER trgDeleteItems
ON MyTable 
FOR DELETE
AS
INSERT INTO MyTableHistory --add a column for user id or put your logic here so that you have your desired data
Select * from deleted 




more information about triggers

Ionut
Was This Post Helpful? 1
  • +
  • -

#3 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5780
  • View blog
  • Posts: 12,596
  • Joined: 16-October 07

Re: Find who deleted the record in the table of sql server 2008

Posted 09 October 2010 - 04:23 AM

I agree with the auditing trigger above. If you have to ask now, it's probably too late. You place such mechanisms in before need them.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1