Wikipedia:Reference desk/Archives/Computing/2023 August 21

= August 21 =

Microsoft SQL Server: Is it possible to find out the SQL command which triggered deletion?
We are having a problem at work. We are developing a .NET C# application that uses a Microsoft SQL Server database. Reports from customers are routinely showing that rows from a database table are disappearing sporadically. We can't reproduce this at our own end.

My colleague has added a database trigger that fires every time a row from the table is deleted and outputs the time of its deletion, and I have taken it to use in the code. But this might not be enough to debug the problem. Is it somehow possible to find out which actual SQL command it was that triggered the deletion? J I P &#124; Talk 21:01, 21 August 2023 (UTC)
 * Here is a web page that might be what you're looking for:  It doesn't show getting the SQL command exactly, but it shows how to find the delete action in the log and then how to use that to find the database user that ran the delete command.  Maybe that will point you in the right direction?  RudolfRed (talk) 00:09, 22 August 2023 (UTC)