Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2003
    Posts
    49

    Unanswered: Using Stored Procedues to start/stop sql profiler

    Does anyone know if there is a way to create a stored procedure that can start sql profiler when executed, and create another stored procedure that stops the profiler when it is executed. I also want the stored procedures to create, and save a trace file in a directory. I am trying this so my developers can collect traces on their apps. Thanks.

  2. #2
    Join Date
    Sep 2003
    Posts
    522
    in my apps i accomplish this "tracing" by having a per-client application execution config option TRACE/NOTRACE. the front-end has one statement execution sub, that checks if this option is set, - record the statement into a designated table prior to executing it. very convenient for debugging!

  3. #3
    Join Date
    Sep 2003
    Posts
    49

    Talking

    I am new to SQL Server advanced programming. Can you show me an example of how you did your trace. Thanks.

  4. #4
    Join Date
    Sep 2003
    Posts
    522
    Code:
    public sub ExecuteSQL(byref obj as object, mSQL as string)
       if mTRACEON then
          conn.execute("insert dbo.trace_table (user_id, computer_id, date_executed, statement) values ('" & getuser() & "', '" & getcomputer() & "', '" & date & " " & time() & "', '" & fixstring(mSQL) & "')"
       end if
       if typename(obj) <> "Nothing" then
          set obj = conn.execute(mSQL)
       else
          conn.execute mSQL
       end if
    end sub

  5. #5
    Join Date
    Sep 2003
    Posts
    49
    thanks. Iwill give it a try.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •