trace question

  • Is there a way to save a sql server 2008 trace as a sql statement?

  • Do you mean a script of the code that creates the trade?

  • nah. when i build a trace to say return everything w reads over 1000 i was hoping the trace had an export script to sql and maybe it would show me the sql used behind the scenes for the trace

  • BaldingLoopMan (8/21/2012)


    nah. when i build a trace to say return everything w reads over 1000 i was hoping the trace had an export script to sql and maybe it would show me the sql used behind the scenes for the trace

    oh yeah I saw a while back there is no easy way to script out existing traces.

    I threw an article out a few years ago, and the script has evolved a little bit since then:

    Reverse Engineering a Server Side Trace[/url]

    my best script to date can be found at this link here:

    sp_ScriptAnyTrace.txt

    usage is super easy, it's simply exec sp_scriptAnyTrace 2, to script trace#2 for example; you might need to peek at sys.traces to get the traceid first.

    i don't know if it's possible to update that article, the script is quite a bit better than what i wrote two years ago.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • If you're runnign the trace from Profiler, stop the trace, file > export > script trace definition.

    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
  • GilaMonster (8/21/2012)


    If you're runnign the trace from Profiler, stop the trace, file > export > script trace definition.

    That's what I'd do. I'd use Profiler to set up the trace, then script it and run as Server side.

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

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