0

I have a SQL Server table where rows randomly get deleted. I want to check what is causing this as I see no issues from the application side.

I did create an after delete trigger and I am able to see which rows are being deleted, but that is still not helping pin-point on why some records are being deleted.

I am wondering if it is possible to log/track which executed SQL statement are deleting the rows from my table.

Please note I am using SQL Server 2016 Express edition.

0
3

You can use the help of SQL Profiler ..

Inside the profiler you can choose the events against your server..

enter image description here

enter image description here

enter image description here

4
  • Thanks so much, that is exactly what i was looking for, do you know if you can target a specific database or table – user1704812 Aug 26 '16 at 16:14
  • you can specify the database..please see the updated answer.. – Unnikrishnan R Aug 26 '16 at 16:19
  • Thanks so much, what about a particular table in that database, or is that asking too much lol – user1704812 Aug 26 '16 at 16:54
  • i think in the objectName you can specify your table.. :) – Unnikrishnan R Aug 26 '16 at 17:03
2

You can't use triggers to trace queries

You can use Extended events to track DML against a particular table.They are light weight in nature and you also can use them to log to disk for later analysis..

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy