Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display deleted rows T-SQL

Help, please. Is there any other way to display deleted rows in SQL Server except for using trigger and deleted table or writing SELECT before DELETE with the same WHERE clause?

like image 721
Alecs Avatar asked Jul 30 '11 21:07

Alecs


People also ask

How do I find deleted rows in SQL Server?

Recover Deleted Data in SQL Server Using LSN: LSNs (Log Sequence Numbers) are special identifiers that are allocated to each record in the SQL Server exchange logs. Subsequently, erased columns of SQL tables are recoverable if the time of their deletion is known.

How do you check who deleted data from table in SQL Server?

Now, to get the complete detail of that user, you can pass [Transaction SID] within suser_sname() function. After executing the above command, you will be able to find out who deleted data from table in SQL Server.


1 Answers

You can use the output clause of the delete statement.

delete from yourtable 
output deleted.*
where ...
like image 193
Mikael Eriksson Avatar answered Oct 13 '22 21:10

Mikael Eriksson