Cannot delete trace files

  • I created some trace files with a SQL Jobs. Now that the jobs have finished & I'm finished with the trace files, I want to delete the files. I get a error stating that another process has the files. I tried restarting SQL Agent, but that didn't help. I tried using XP_delete_files, but the files are not backup files, so that didn't work either. How do I delete the files?

  • check if the trace is still exists.

    SELECT id,status,path

    FROM sys.traces

    If it exists and is running(status 1) you wont be able to delete the file. Even if the trace is not running (status 0) it appears you wont be able to delete the file. I did a quick test and after stopping the trace i was unable to delete the file until I removed the trace definition.

    exec sp_trace_setstatus <traceid>, 2

    note: if you don't recreate your trace as part of your job then don't remove the trace as the trace definition will no longer be in you instance.

    Bob
    -----------------------------------------------------------------------------
    How to post to get the best help[/url]

  • Thank you - that worked.

    The correct syntax is

    sp_trace_setstatus [ @traceid = ] trace_id , [ @status = ] status

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply