How can I find who deleted the record in the table in SQL Server 2008?
2 Replies - 7169 Views - Last Post: 09 October 2010 - 04:23 AM
#1
Find who deleted the record in the table of sql server 2008
Posted 09 October 2010 - 12:57 AM
Replies To: Find who deleted the record in the table of sql server 2008
#2
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
more information about triggers
Ionut
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
#3
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.
Page 1 of 1