|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 1:22 PM
Points: 66,
Visits: 254
|
|
Guys, after I create, run, stop, and delete the trace, I cannot ever seem to open the resulting file with Profiler: "Access denied". I'm assuming something still has it locked.
I am able to view it using fn_trace_gettable().
Am I missing a step?
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 1:22 PM
Points: 66,
Visits: 254
|
|
Grubb (4/8/2011) Guys, after I create, run, stop, and delete the trace, I cannot ever seem to open the resulting file with Profiler: "Access denied". I'm assuming something still has it locked.
I am able to view it using fn_trace_gettable().
Am I missing a step?
Nevermind...It was truly a permissions issue. It's fun being a DBA without local admin access
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, March 25, 2013 8:18 AM
Points: 3,
Visits: 20
|
|
Hey I am getting an error on adding the event
DECLARE @return_code INT; DECLARE @TraceID INT; DECLARE @maxfilesize BIGINT; SET @maxfilesize = 5; --step 1: create a new empty trace definition EXEC sp_trace_create @traceid OUTPUT , @options = 2 , @tracefile = N'd:\LongRunningQueries' , @maxfilesize = @maxfilesize , @stoptime =NULL , @filecount = 2; -- step 2: add the events and columns EXEC sp_trace_setevent @traceid = @TraceID , @eventid = 10 -- RPC:Completed , @columnid = 1 -- TextData , @on = 1;--include this column in trace
Gives me
Msg 214, Level 16, State 3, Procedure sp_trace_setevent, Line 1 Procedure expects parameter '@on' of type 'bit'.
The trace is created, it's just the event selection that fails I guess (didn't try running it). It's probably something simple, I just can't see it - any bright ideas?
By the way great article, reading it with great interest - only ever used the GUI profiler before (I haven't gotten to section 3 yet, but I hope there is a way of converting the GUI profiler trace setting to a script as mentioned in section 1)
/Jon
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Sunday, May 19, 2013 4:28 PM
Points: 39,
Visits: 229
|
|
Hi, Jon.
Thanks for the positive feedback. I’m glad you found this Stairway informative.
It looks like you are using SQL 2005, which is a bit pickier regarding the bit data type parameter passed to sp_trace_setevent. Just declare and initialize a local variable of type bit for the parameter like the example below. You can pass the literal directly in SQL 2008 and later versions without the need for the local variable.
DECLARE @return_code INT; DECLARE @TraceID INT; DECLARE @maxfilesize BIGINT; SET @maxfilesize = 5;
--SQL 2005 needs local variable for bit value DECLARE @on bit SET @on = 1;
SET @maxfilesize = 5;
--step 1: create a new empty trace definition EXEC sp_trace_create @traceid OUTPUT , @options = 2 , @tracefile = N'd:\LongRunningQueries' , @maxfilesize = @maxfilesize , @stoptime =NULL , @filecount = 2;
-- step 2: add the events and columns EXEC sp_trace_setevent @traceid = @TraceID , @eventid = 10 -- RPC:Completed , @columnid = 1 -- TextData , @on = @on; --include this column in trace
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, March 25, 2013 8:18 AM
Points: 3,
Visits: 20
|
|
Awesome! Thanks a lot, that works great 
/Jon
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 2:37 PM
Points: 170,
Visits: 388
|
|
I am following the same way as in script..but receiving the folowing error on Step 2:
Must declare the scalar variable "@TraceID".
Any suggestions..do we need to declare any traceid value
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, March 25, 2013 8:18 AM
Points: 3,
Visits: 20
|
|
Hey
If you didn't remove the line:
DECLARE @TraceID INT; You are declaring it, so I would check for misspellings, left out lines, or if you do a GO inbetween /Jon
DBA_Learner (9/12/2012) I am following the same way as in script..but receiving the folowing error on Step 2:
Must declare the scalar variable "@TraceID".
Any suggestions..do we need to declare any traceid value
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 2:37 PM
Points: 170,
Visits: 388
|
|
Thanks for response. It is now working fine. But, I have a question.
Now in msdn sites for sp_trace_setevent / sp_trace_setfilter / sp_trace_setstatus , I see the following WARNING message.
/* This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use Extended Events instead. */
So, can anyone explain me what is this Extended events mean?
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Tuesday, March 19, 2013 7:24 AM
Points: 467,
Visits: 1,681
|
|
|
|
|