Scripting a trace

  • I'm creating a script that will create a trace on a production server.  I have 95% of the script completed but I can't see where it will let me save the output of the trace to a table rather than a file.

    The purpose of the trace is to get a list of every object touched (I'm using the permission events).  Then to conserve space every 24 hours I'm going to kill the trace and move the data into a summary table (basically just the object/db name and a count for the day.  Then I want to start the trace over again.

    I'm using sp_trace_create but it only has a @tracefile parameter.

    Any suggestions?

    Thanks

    Ken

    Kenneth FisherI was once offered a wizards hat but it got in the way of my dunce cap.--------------------------------------------------------------------------------For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/[/url]Link to my Blog Post --> www.SQLStudies.com[/url]

  • Ken,

    As far as I know with sp_trace_create you cannot write to a table directly. One way around it is if you write to a file, stop the trace using sp_trace_setstatus, and then use fn_trace_gettable.

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • I've just found an article by Andy Warren that may be useful (the result is the same)

    http://www.sqlservercentral.com/columnists/awarren/profilerloggingresultstoatable.asp

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • Yea,  I had seen that option.  I was just hoping that there was something a bit more elegant.

    Thanks

    Ken

    Kenneth FisherI was once offered a wizards hat but it got in the way of my dunce cap.--------------------------------------------------------------------------------For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/[/url]Link to my Blog Post --> www.SQLStudies.com[/url]

  • for the record SQL 2005 *can* read "opened" tracefiles.


    * Noel

Viewing 5 posts - 1 through 4 (of 4 total)

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