How to script a profiler trace in SQL Server 2008

  • I want to run a trace on schedule. can any one tell me how to script a SQL Server profiler trace? So that i can put it in a scheduled job.

    Thanks in advance.

  • Start with sp_trace_create. Check that on MSDN, and it'll refer you to sp_trace_setevent, fn_trace_getinfo, and all the rest.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Open the profiler GUI, set up the trace you want (against a dev server). Run. Stop. File -> Export -> Script trace definition.

    Open the resultant file in Management Studio and edit as necessary.

    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
  • Thank you very much Guys......... It helps me a lot.

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

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