Can i schedule a sql trace through script and have data write to table

  • Is there a way to schedule a sql trace through script and have it write directly to a table?

  • Yes you can ..Google "Server side tracing in SQL Server".Place the trace script in a SQL job and schedule it and using fn_trace_gettable read the trace file to insert the trace data in the table.

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server

  • Sachin Nandanwar (3/23/2016)


    Yes you can ..Google "Server side tracing in SQL Server".Place the trace script in a SQL job and schedule it and using fn_trace_gettable read the trace file to insert the trace data in the table.

    I do understand that, my question was when i schedule a trace , can i directly write it to a trace.

  • No you can't. Writing directly to a table is a feature of the Profiler GUI (and is usually a bad idea, especially if writing to the instance being traced)

    Schedule your trace to write to a file, afterwards import the trace with the fn_trace_getdata function. If you want, you can schedule that part too.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

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

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