Sql-server – Deletion of SQL Profiler Trace files (.trc)

sql servertrace

We've noticed a lot of .trc files in our SQL data folder (\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data) on our server. The date range for these files spans over one day and the total file size of all files together is about 21 gigs. I'd like to free up this space but I'm not sure if I can just delete the files manually through Windows Explorer or if I need to do anything in SQL, like run a command or script. Any ideas?

Best Answer

The .trc files are safe to delete.

.trc files generated by SQL Server in process of saving events to a physical file without using the Profiler client tool. Server-side tracing is enabled and controlled by using SQL Server system-supplied stored procedures and functions. With these system-supplied processes, you can identify what to trace, when to start and stop tracing, what traces are running, and view trace information stored in the trace file.

View the number of currently running traces :

SELECT count(*) FROM :: fn_trace_getinfo(default) WHERE property = 5 and value = 1

More detail about the running traces:

SELECT * FROM :: fn_trace_getinfo(default)

You can terminate a trace with the 'sp_trace_setstatus' stored procedure using the traceid:

EXEC sp_trace_setstatus 1, @status = 0
EXEC sp_trace_setstatus 1, @status = 2

Setting the status to 0 stops the trace Setting the status to 2 closes the trace and deletes its definition from the server

Good Luck!