Setting up Trace in SQL Server 2012 to track the deletion in a Table
Hi Everyone
Today we'll be going through one of the issues I faced at my workplace.
The issue was that records were being deleted from the DB table.
Only service I knew was inserting records into the Table.
Basically, in such scenario, we use the SQL Server Profiler.
This is available in the Menu of Performance Tools under SQL Server 2012.
Open the profiler:
Click File >> New Trace.
This will ask for the server against which you want to run the trace.
Enter the Server Instance and the credentials.
This will open up the Trace Properties Window.
Use the Standard Template for the moment
You can save the trace data to a file with a .trc extension. However, better approach can be saving to a database table. This all depends upon personal preference.
Also, the trace can be time based. You can mention a time at which the trace ends. This is quite necessary as the trace can be quite resource consuming at times.
Now, go to the Events Selection tab.
There are some events selected by default. Uncheck all those, as we they don't fit the requirements.
Check Show All Events and Show All Columns, here you can use the events as per the requirement.
We went to TSQL and selected something as shown
Then we did the same for Stored Procedures.
Now , we have the required events. However, this would capture huge amount of data. So we need to filter it.Click on column filters on the right hand lower side.
We click on the Database Name and Add the filter on like '%DBName%' where DBName is the name of your database.
Similarly, add a filter for the field Textdata with like '%TableName%'.
Now , finally click on Run and this will keep on running until the time given.
And will provide the results in the database table or a file as given.
Profiler is an amazing thing which can be used in multiple scenarios using different events, columns and filters.
Comments
Post a Comment