• Thanks for this article. it was just what I needed and a feature I did not know about. I have been experimenting and it looks great however I get an error if the trace file already exists as a new one cannot be created (as you would expect). Is there a way of setting the output file name to be something that changes on each execution?

    I have tried to create a variable for the file name and concatenating to this the date but this does not seem to work either.

    Declare @SaveTo varchar(max)

    Set @Saveto = 'C:\DirName\'+ (cast(Getdate()as char))

    exec @rc = sp_trace_create @TraceID output, 2, @Saveto, @maxfilesize, @stoptime,NULL

    I get an error of ‘Procedure expects parameter '@tracefile' of type 'nvarchar(256)'.’

    Any Suggestions?