How to get SQL Trace to capture more details on an error

  • Hello experts,

    I'm trying to track down an error from a client connecting via PHP that tries to run a SELECT statement against a view. I have used a server-side trace to try to narrow down the cause of the error, but so far all I get are the following clues:

    Reported error:

    Error [MYSERVER]: [256] Invalid query: Query failed Changed database context to 'MyDatabase'.

    Whole query: SELECT [fld1],[fld2] from [MyDatabase].[dbo].[MyView];

    EventClass: 12

    Error: 2

    I have added what I think are all the events related to tracing errors, warnings, and exceptions, but to no avail (see the trace definition below). Does anyone know how I might get SQL Trace to report more - if in fact in can in this case?

    Some additional info - the same connection is made other days at the same time without this error, and we have already tried setting the login's default database to the 'MyDatabase' also without success - i.e. the error above still happens sporadically.

    Our best guess at this point is that somehow the current scheduled task timing is being interfered with by some other process, but rather than just experimenting blindly with different times we want to find out why the error is happening when it does.

    Thanks for any help!!

    - webrunner

    /****************************************************/

    /* Created by: SQL Server 2012 Profiler */

    /* Date: 01/20/2016 12:02:05 AM */

    /****************************************************/

    -- Create a Queue

    declare @rc int

    declare @TraceID int

    declare @maxfilesize bigint

    declare @DateTime datetime

    set @DateTime = '2016-01-29 17:00:00.000'

    set @maxfilesize = 15

    -- Please replace the text InsertFileNameHere, with an appropriate

    -- filename prefixed by a path, e.g., c:\MyFolder\MyTrace. The .trc extension

    -- will be appended to the filename automatically. If you are writing from

    -- remote server to local drive, please use UNC path and make sure server has

    -- write access to your network share

    exec @rc = sp_trace_create @TraceID output, 2, N'E:\Traces\MyTrace', @maxfilesize, @Datetime

    if (@rc != 0) goto error

    -- Client side File and Table cannot be scripted

    -- Set the events

    declare @on bit

    set @on = 1

    exec sp_trace_setevent @TraceID, 125, 1, @on

    exec sp_trace_setevent @TraceID, 125, 9, @on

    exec sp_trace_setevent @TraceID, 125, 3, @on

    exec sp_trace_setevent @TraceID, 125, 11, @on

    exec sp_trace_setevent @TraceID, 125, 4, @on

    exec sp_trace_setevent @TraceID, 125, 6, @on

    exec sp_trace_setevent @TraceID, 125, 7, @on

    exec sp_trace_setevent @TraceID, 125, 8, @on

    exec sp_trace_setevent @TraceID, 125, 10, @on

    exec sp_trace_setevent @TraceID, 125, 12, @on

    exec sp_trace_setevent @TraceID, 125, 14, @on

    exec sp_trace_setevent @TraceID, 125, 22, @on

    exec sp_trace_setevent @TraceID, 125, 26, @on

    exec sp_trace_setevent @TraceID, 125, 34, @on

    exec sp_trace_setevent @TraceID, 125, 35, @on

    exec sp_trace_setevent @TraceID, 125, 41, @on

    exec sp_trace_setevent @TraceID, 125, 49, @on

    exec sp_trace_setevent @TraceID, 125, 50, @on

    exec sp_trace_setevent @TraceID, 125, 51, @on

    exec sp_trace_setevent @TraceID, 125, 55, @on

    exec sp_trace_setevent @TraceID, 125, 60, @on

    exec sp_trace_setevent @TraceID, 125, 61, @on

    exec sp_trace_setevent @TraceID, 125, 63, @on

    exec sp_trace_setevent @TraceID, 125, 64, @on

    exec sp_trace_setevent @TraceID, 126, 1, @on

    exec sp_trace_setevent @TraceID, 126, 9, @on

    exec sp_trace_setevent @TraceID, 126, 3, @on

    exec sp_trace_setevent @TraceID, 126, 11, @on

    exec sp_trace_setevent @TraceID, 126, 4, @on

    exec sp_trace_setevent @TraceID, 126, 6, @on

    exec sp_trace_setevent @TraceID, 126, 7, @on

    exec sp_trace_setevent @TraceID, 126, 8, @on

    exec sp_trace_setevent @TraceID, 126, 10, @on

    exec sp_trace_setevent @TraceID, 126, 12, @on

    exec sp_trace_setevent @TraceID, 126, 14, @on

    exec sp_trace_setevent @TraceID, 126, 22, @on

    exec sp_trace_setevent @TraceID, 126, 26, @on

    exec sp_trace_setevent @TraceID, 126, 34, @on

    exec sp_trace_setevent @TraceID, 126, 35, @on

    exec sp_trace_setevent @TraceID, 126, 41, @on

    exec sp_trace_setevent @TraceID, 126, 49, @on

    exec sp_trace_setevent @TraceID, 126, 50, @on

    exec sp_trace_setevent @TraceID, 126, 51, @on

    exec sp_trace_setevent @TraceID, 126, 55, @on

    exec sp_trace_setevent @TraceID, 126, 60, @on

    exec sp_trace_setevent @TraceID, 126, 61, @on

    exec sp_trace_setevent @TraceID, 126, 63, @on

    exec sp_trace_setevent @TraceID, 126, 64, @on

    exec sp_trace_setevent @TraceID, 16, 3, @on

    exec sp_trace_setevent @TraceID, 16, 11, @on

    exec sp_trace_setevent @TraceID, 16, 4, @on

    exec sp_trace_setevent @TraceID, 16, 12, @on

    exec sp_trace_setevent @TraceID, 16, 6, @on

    exec sp_trace_setevent @TraceID, 16, 7, @on

    exec sp_trace_setevent @TraceID, 16, 8, @on

    exec sp_trace_setevent @TraceID, 16, 9, @on

    exec sp_trace_setevent @TraceID, 16, 10, @on

    exec sp_trace_setevent @TraceID, 16, 13, @on

    exec sp_trace_setevent @TraceID, 16, 14, @on

    exec sp_trace_setevent @TraceID, 16, 15, @on

    exec sp_trace_setevent @TraceID, 16, 26, @on

    exec sp_trace_setevent @TraceID, 16, 35, @on

    exec sp_trace_setevent @TraceID, 16, 41, @on

    exec sp_trace_setevent @TraceID, 16, 49, @on

    exec sp_trace_setevent @TraceID, 16, 51, @on

    exec sp_trace_setevent @TraceID, 16, 60, @on

    exec sp_trace_setevent @TraceID, 16, 64, @on

    exec sp_trace_setevent @TraceID, 22, 1, @on

    exec sp_trace_setevent @TraceID, 22, 9, @on

    exec sp_trace_setevent @TraceID, 22, 3, @on

    exec sp_trace_setevent @TraceID, 22, 11, @on

    exec sp_trace_setevent @TraceID, 22, 4, @on

    exec sp_trace_setevent @TraceID, 22, 6, @on

    exec sp_trace_setevent @TraceID, 22, 7, @on

    exec sp_trace_setevent @TraceID, 22, 8, @on

    exec sp_trace_setevent @TraceID, 22, 10, @on

    exec sp_trace_setevent @TraceID, 22, 12, @on

    exec sp_trace_setevent @TraceID, 22, 14, @on

    exec sp_trace_setevent @TraceID, 22, 20, @on

    exec sp_trace_setevent @TraceID, 22, 26, @on

    exec sp_trace_setevent @TraceID, 22, 30, @on

    exec sp_trace_setevent @TraceID, 22, 31, @on

    exec sp_trace_setevent @TraceID, 22, 35, @on

    exec sp_trace_setevent @TraceID, 22, 41, @on

    exec sp_trace_setevent @TraceID, 22, 49, @on

    exec sp_trace_setevent @TraceID, 22, 51, @on

    exec sp_trace_setevent @TraceID, 22, 60, @on

    exec sp_trace_setevent @TraceID, 22, 64, @on

    exec sp_trace_setevent @TraceID, 33, 1, @on

    exec sp_trace_setevent @TraceID, 33, 9, @on

    exec sp_trace_setevent @TraceID, 33, 3, @on

    exec sp_trace_setevent @TraceID, 33, 11, @on

    exec sp_trace_setevent @TraceID, 33, 4, @on

    exec sp_trace_setevent @TraceID, 33, 6, @on

    exec sp_trace_setevent @TraceID, 33, 7, @on

    exec sp_trace_setevent @TraceID, 33, 8, @on

    exec sp_trace_setevent @TraceID, 33, 10, @on

    exec sp_trace_setevent @TraceID, 33, 12, @on

    exec sp_trace_setevent @TraceID, 33, 14, @on

    exec sp_trace_setevent @TraceID, 33, 20, @on

    exec sp_trace_setevent @TraceID, 33, 26, @on

    exec sp_trace_setevent @TraceID, 33, 30, @on

    exec sp_trace_setevent @TraceID, 33, 31, @on

    exec sp_trace_setevent @TraceID, 33, 35, @on

    exec sp_trace_setevent @TraceID, 33, 41, @on

    exec sp_trace_setevent @TraceID, 33, 49, @on

    exec sp_trace_setevent @TraceID, 33, 50, @on

    exec sp_trace_setevent @TraceID, 33, 51, @on

    exec sp_trace_setevent @TraceID, 33, 60, @on

    exec sp_trace_setevent @TraceID, 33, 64, @on

    exec sp_trace_setevent @TraceID, 33, 66, @on

    exec sp_trace_setevent @TraceID, 67, 1, @on

    exec sp_trace_setevent @TraceID, 67, 9, @on

    exec sp_trace_setevent @TraceID, 67, 3, @on

    exec sp_trace_setevent @TraceID, 67, 11, @on

    exec sp_trace_setevent @TraceID, 67, 4, @on

    exec sp_trace_setevent @TraceID, 67, 6, @on

    exec sp_trace_setevent @TraceID, 67, 7, @on

    exec sp_trace_setevent @TraceID, 67, 8, @on

    exec sp_trace_setevent @TraceID, 67, 10, @on

    exec sp_trace_setevent @TraceID, 67, 12, @on

    exec sp_trace_setevent @TraceID, 67, 13, @on

    exec sp_trace_setevent @TraceID, 67, 14, @on

    exec sp_trace_setevent @TraceID, 67, 21, @on

    exec sp_trace_setevent @TraceID, 67, 26, @on

    exec sp_trace_setevent @TraceID, 67, 31, @on

    exec sp_trace_setevent @TraceID, 67, 35, @on

    exec sp_trace_setevent @TraceID, 67, 41, @on

    exec sp_trace_setevent @TraceID, 67, 49, @on

    exec sp_trace_setevent @TraceID, 67, 50, @on

    exec sp_trace_setevent @TraceID, 67, 51, @on

    exec sp_trace_setevent @TraceID, 67, 60, @on

    exec sp_trace_setevent @TraceID, 67, 64, @on

    exec sp_trace_setevent @TraceID, 67, 66, @on

    exec sp_trace_setevent @TraceID, 162, 1, @on

    exec sp_trace_setevent @TraceID, 162, 9, @on

    exec sp_trace_setevent @TraceID, 162, 3, @on

    exec sp_trace_setevent @TraceID, 162, 11, @on

    exec sp_trace_setevent @TraceID, 162, 4, @on

    exec sp_trace_setevent @TraceID, 162, 6, @on

    exec sp_trace_setevent @TraceID, 162, 7, @on

    exec sp_trace_setevent @TraceID, 162, 8, @on

    exec sp_trace_setevent @TraceID, 162, 10, @on

    exec sp_trace_setevent @TraceID, 162, 12, @on

    exec sp_trace_setevent @TraceID, 162, 14, @on

    exec sp_trace_setevent @TraceID, 162, 20, @on

    exec sp_trace_setevent @TraceID, 162, 26, @on

    exec sp_trace_setevent @TraceID, 162, 30, @on

    exec sp_trace_setevent @TraceID, 162, 31, @on

    exec sp_trace_setevent @TraceID, 162, 35, @on

    exec sp_trace_setevent @TraceID, 162, 41, @on

    exec sp_trace_setevent @TraceID, 162, 49, @on

    exec sp_trace_setevent @TraceID, 162, 50, @on

    exec sp_trace_setevent @TraceID, 162, 51, @on

    exec sp_trace_setevent @TraceID, 162, 60, @on

    exec sp_trace_setevent @TraceID, 162, 64, @on

    exec sp_trace_setevent @TraceID, 162, 66, @on

    exec sp_trace_setevent @TraceID, 180, 1, @on

    exec sp_trace_setevent @TraceID, 180, 2, @on

    exec sp_trace_setevent @TraceID, 180, 10, @on

    exec sp_trace_setevent @TraceID, 180, 3, @on

    exec sp_trace_setevent @TraceID, 180, 11, @on

    exec sp_trace_setevent @TraceID, 180, 4, @on

    exec sp_trace_setevent @TraceID, 180, 6, @on

    exec sp_trace_setevent @TraceID, 180, 7, @on

    exec sp_trace_setevent @TraceID, 180, 8, @on

    exec sp_trace_setevent @TraceID, 180, 12, @on

    exec sp_trace_setevent @TraceID, 180, 14, @on

    exec sp_trace_setevent @TraceID, 180, 19, @on

    exec sp_trace_setevent @TraceID, 180, 23, @on

    exec sp_trace_setevent @TraceID, 180, 26, @on

    exec sp_trace_setevent @TraceID, 180, 28, @on

    exec sp_trace_setevent @TraceID, 180, 29, @on

    exec sp_trace_setevent @TraceID, 180, 34, @on

    exec sp_trace_setevent @TraceID, 180, 35, @on

    exec sp_trace_setevent @TraceID, 180, 37, @on

    exec sp_trace_setevent @TraceID, 180, 40, @on

    exec sp_trace_setevent @TraceID, 180, 41, @on

    exec sp_trace_setevent @TraceID, 180, 49, @on

    exec sp_trace_setevent @TraceID, 180, 50, @on

    exec sp_trace_setevent @TraceID, 180, 51, @on

    exec sp_trace_setevent @TraceID, 180, 60, @on

    exec sp_trace_setevent @TraceID, 180, 64, @on

    exec sp_trace_setevent @TraceID, 20, 1, @on

    exec sp_trace_setevent @TraceID, 20, 9, @on

    exec sp_trace_setevent @TraceID, 20, 3, @on

    exec sp_trace_setevent @TraceID, 20, 11, @on

    exec sp_trace_setevent @TraceID, 20, 6, @on

    exec sp_trace_setevent @TraceID, 20, 7, @on

    exec sp_trace_setevent @TraceID, 20, 8, @on

    exec sp_trace_setevent @TraceID, 20, 10, @on

    exec sp_trace_setevent @TraceID, 20, 12, @on

    exec sp_trace_setevent @TraceID, 20, 14, @on

    exec sp_trace_setevent @TraceID, 20, 21, @on

    exec sp_trace_setevent @TraceID, 20, 23, @on

    exec sp_trace_setevent @TraceID, 20, 26, @on

    exec sp_trace_setevent @TraceID, 20, 30, @on

    exec sp_trace_setevent @TraceID, 20, 31, @on

    exec sp_trace_setevent @TraceID, 20, 35, @on

    exec sp_trace_setevent @TraceID, 20, 49, @on

    exec sp_trace_setevent @TraceID, 20, 51, @on

    exec sp_trace_setevent @TraceID, 20, 57, @on

    exec sp_trace_setevent @TraceID, 20, 60, @on

    exec sp_trace_setevent @TraceID, 20, 64, @on

    exec sp_trace_setevent @TraceID, 113, 1, @on

    exec sp_trace_setevent @TraceID, 113, 9, @on

    exec sp_trace_setevent @TraceID, 113, 2, @on

    exec sp_trace_setevent @TraceID, 113, 3, @on

    exec sp_trace_setevent @TraceID, 113, 4, @on

    exec sp_trace_setevent @TraceID, 113, 5, @on

    exec sp_trace_setevent @TraceID, 113, 6, @on

    exec sp_trace_setevent @TraceID, 113, 7, @on

    exec sp_trace_setevent @TraceID, 113, 8, @on

    exec sp_trace_setevent @TraceID, 113, 10, @on

    exec sp_trace_setevent @TraceID, 113, 11, @on

    exec sp_trace_setevent @TraceID, 113, 12, @on

    exec sp_trace_setevent @TraceID, 113, 14, @on

    exec sp_trace_setevent @TraceID, 113, 19, @on

    exec sp_trace_setevent @TraceID, 113, 21, @on

    exec sp_trace_setevent @TraceID, 113, 23, @on

    exec sp_trace_setevent @TraceID, 113, 26, @on

    exec sp_trace_setevent @TraceID, 113, 28, @on

    exec sp_trace_setevent @TraceID, 113, 29, @on

    exec sp_trace_setevent @TraceID, 113, 35, @on

    exec sp_trace_setevent @TraceID, 113, 40, @on

    exec sp_trace_setevent @TraceID, 113, 41, @on

    exec sp_trace_setevent @TraceID, 113, 49, @on

    exec sp_trace_setevent @TraceID, 113, 50, @on

    exec sp_trace_setevent @TraceID, 113, 51, @on

    exec sp_trace_setevent @TraceID, 113, 60, @on

    exec sp_trace_setevent @TraceID, 113, 64, @on

    exec sp_trace_setevent @TraceID, 10, 1, @on

    exec sp_trace_setevent @TraceID, 10, 9, @on

    exec sp_trace_setevent @TraceID, 10, 2, @on

    exec sp_trace_setevent @TraceID, 10, 66, @on

    exec sp_trace_setevent @TraceID, 10, 10, @on

    exec sp_trace_setevent @TraceID, 10, 3, @on

    exec sp_trace_setevent @TraceID, 10, 4, @on

    exec sp_trace_setevent @TraceID, 10, 6, @on

    exec sp_trace_setevent @TraceID, 10, 7, @on

    exec sp_trace_setevent @TraceID, 10, 8, @on

    exec sp_trace_setevent @TraceID, 10, 11, @on

    exec sp_trace_setevent @TraceID, 10, 12, @on

    exec sp_trace_setevent @TraceID, 10, 13, @on

    exec sp_trace_setevent @TraceID, 10, 14, @on

    exec sp_trace_setevent @TraceID, 10, 15, @on

    exec sp_trace_setevent @TraceID, 10, 16, @on

    exec sp_trace_setevent @TraceID, 10, 17, @on

    exec sp_trace_setevent @TraceID, 10, 18, @on

    exec sp_trace_setevent @TraceID, 10, 25, @on

    exec sp_trace_setevent @TraceID, 10, 26, @on

    exec sp_trace_setevent @TraceID, 10, 31, @on

    exec sp_trace_setevent @TraceID, 10, 34, @on

    exec sp_trace_setevent @TraceID, 10, 35, @on

    exec sp_trace_setevent @TraceID, 10, 41, @on

    exec sp_trace_setevent @TraceID, 10, 48, @on

    exec sp_trace_setevent @TraceID, 10, 49, @on

    exec sp_trace_setevent @TraceID, 10, 50, @on

    exec sp_trace_setevent @TraceID, 10, 51, @on

    exec sp_trace_setevent @TraceID, 10, 60, @on

    exec sp_trace_setevent @TraceID, 10, 64, @on

    exec sp_trace_setevent @TraceID, 43, 1, @on

    exec sp_trace_setevent @TraceID, 43, 9, @on

    exec sp_trace_setevent @TraceID, 43, 2, @on

    exec sp_trace_setevent @TraceID, 43, 66, @on

    exec sp_trace_setevent @TraceID, 43, 3, @on

    exec sp_trace_setevent @TraceID, 43, 4, @on

    exec sp_trace_setevent @TraceID, 43, 5, @on

    exec sp_trace_setevent @TraceID, 43, 6, @on

    exec sp_trace_setevent @TraceID, 43, 7, @on

    exec sp_trace_setevent @TraceID, 43, 8, @on

    exec sp_trace_setevent @TraceID, 43, 10, @on

    exec sp_trace_setevent @TraceID, 43, 11, @on

    exec sp_trace_setevent @TraceID, 43, 12, @on

    exec sp_trace_setevent @TraceID, 43, 13, @on

    exec sp_trace_setevent @TraceID, 43, 14, @on

    exec sp_trace_setevent @TraceID, 43, 15, @on

    exec sp_trace_setevent @TraceID, 43, 22, @on

    exec sp_trace_setevent @TraceID, 43, 26, @on

    exec sp_trace_setevent @TraceID, 43, 28, @on

    exec sp_trace_setevent @TraceID, 43, 29, @on

    exec sp_trace_setevent @TraceID, 43, 34, @on

    exec sp_trace_setevent @TraceID, 43, 35, @on

    exec sp_trace_setevent @TraceID, 43, 41, @on

    exec sp_trace_setevent @TraceID, 43, 48, @on

    exec sp_trace_setevent @TraceID, 43, 49, @on

    exec sp_trace_setevent @TraceID, 43, 50, @on

    exec sp_trace_setevent @TraceID, 43, 51, @on

    exec sp_trace_setevent @TraceID, 43, 60, @on

    exec sp_trace_setevent @TraceID, 43, 62, @on

    exec sp_trace_setevent @TraceID, 43, 64, @on

    exec sp_trace_setevent @TraceID, 45, 1, @on

    exec sp_trace_setevent @TraceID, 45, 9, @on

    exec sp_trace_setevent @TraceID, 45, 3, @on

    exec sp_trace_setevent @TraceID, 45, 4, @on

    exec sp_trace_setevent @TraceID, 45, 5, @on

    exec sp_trace_setevent @TraceID, 45, 6, @on

    exec sp_trace_setevent @TraceID, 45, 7, @on

    exec sp_trace_setevent @TraceID, 45, 8, @on

    exec sp_trace_setevent @TraceID, 45, 10, @on

    exec sp_trace_setevent @TraceID, 45, 11, @on

    exec sp_trace_setevent @TraceID, 45, 12, @on

    exec sp_trace_setevent @TraceID, 45, 13, @on

    exec sp_trace_setevent @TraceID, 45, 14, @on

    exec sp_trace_setevent @TraceID, 45, 15, @on

    exec sp_trace_setevent @TraceID, 45, 16, @on

    exec sp_trace_setevent @TraceID, 45, 17, @on

    exec sp_trace_setevent @TraceID, 45, 18, @on

    exec sp_trace_setevent @TraceID, 45, 22, @on

    exec sp_trace_setevent @TraceID, 45, 25, @on

    exec sp_trace_setevent @TraceID, 45, 26, @on

    exec sp_trace_setevent @TraceID, 45, 28, @on

    exec sp_trace_setevent @TraceID, 45, 29, @on

    exec sp_trace_setevent @TraceID, 45, 34, @on

    exec sp_trace_setevent @TraceID, 45, 35, @on

    exec sp_trace_setevent @TraceID, 45, 41, @on

    exec sp_trace_setevent @TraceID, 45, 48, @on

    exec sp_trace_setevent @TraceID, 45, 49, @on

    exec sp_trace_setevent @TraceID, 45, 50, @on

    exec sp_trace_setevent @TraceID, 45, 51, @on

    exec sp_trace_setevent @TraceID, 45, 55, @on

    exec sp_trace_setevent @TraceID, 45, 60, @on

    exec sp_trace_setevent @TraceID, 45, 61, @on

    exec sp_trace_setevent @TraceID, 45, 62, @on

    exec sp_trace_setevent @TraceID, 45, 64, @on

    exec sp_trace_setevent @TraceID, 45, 66, @on

    exec sp_trace_setevent @TraceID, 12, 1, @on

    exec sp_trace_setevent @TraceID, 12, 9, @on

    exec sp_trace_setevent @TraceID, 12, 3, @on

    exec sp_trace_setevent @TraceID, 12, 11, @on

    exec sp_trace_setevent @TraceID, 12, 4, @on

    exec sp_trace_setevent @TraceID, 12, 6, @on

    exec sp_trace_setevent @TraceID, 12, 7, @on

    exec sp_trace_setevent @TraceID, 12, 8, @on

    exec sp_trace_setevent @TraceID, 12, 10, @on

    exec sp_trace_setevent @TraceID, 12, 12, @on

    exec sp_trace_setevent @TraceID, 12, 13, @on

    exec sp_trace_setevent @TraceID, 12, 14, @on

    exec sp_trace_setevent @TraceID, 12, 15, @on

    exec sp_trace_setevent @TraceID, 12, 16, @on

    exec sp_trace_setevent @TraceID, 12, 17, @on

    exec sp_trace_setevent @TraceID, 12, 18, @on

    exec sp_trace_setevent @TraceID, 12, 26, @on

    exec sp_trace_setevent @TraceID, 12, 31, @on

    exec sp_trace_setevent @TraceID, 12, 35, @on

    exec sp_trace_setevent @TraceID, 12, 41, @on

    exec sp_trace_setevent @TraceID, 12, 48, @on

    exec sp_trace_setevent @TraceID, 12, 49, @on

    exec sp_trace_setevent @TraceID, 12, 50, @on

    exec sp_trace_setevent @TraceID, 12, 51, @on

    exec sp_trace_setevent @TraceID, 12, 60, @on

    exec sp_trace_setevent @TraceID, 12, 64, @on

    exec sp_trace_setevent @TraceID, 12, 66, @on

    exec sp_trace_setevent @TraceID, 41, 1, @on

    exec sp_trace_setevent @TraceID, 41, 9, @on

    exec sp_trace_setevent @TraceID, 41, 3, @on

    exec sp_trace_setevent @TraceID, 41, 4, @on

    exec sp_trace_setevent @TraceID, 41, 5, @on

    exec sp_trace_setevent @TraceID, 41, 6, @on

    exec sp_trace_setevent @TraceID, 41, 7, @on

    exec sp_trace_setevent @TraceID, 41, 8, @on

    exec sp_trace_setevent @TraceID, 41, 10, @on

    exec sp_trace_setevent @TraceID, 41, 11, @on

    exec sp_trace_setevent @TraceID, 41, 12, @on

    exec sp_trace_setevent @TraceID, 41, 13, @on

    exec sp_trace_setevent @TraceID, 41, 14, @on

    exec sp_trace_setevent @TraceID, 41, 15, @on

    exec sp_trace_setevent @TraceID, 41, 16, @on

    exec sp_trace_setevent @TraceID, 41, 17, @on

    exec sp_trace_setevent @TraceID, 41, 18, @on

    exec sp_trace_setevent @TraceID, 41, 25, @on

    exec sp_trace_setevent @TraceID, 41, 26, @on

    exec sp_trace_setevent @TraceID, 41, 29, @on

    exec sp_trace_setevent @TraceID, 41, 35, @on

    exec sp_trace_setevent @TraceID, 41, 41, @on

    exec sp_trace_setevent @TraceID, 41, 48, @on

    exec sp_trace_setevent @TraceID, 41, 49, @on

    exec sp_trace_setevent @TraceID, 41, 50, @on

    exec sp_trace_setevent @TraceID, 41, 51, @on

    exec sp_trace_setevent @TraceID, 41, 55, @on

    exec sp_trace_setevent @TraceID, 41, 60, @on

    exec sp_trace_setevent @TraceID, 41, 61, @on

    exec sp_trace_setevent @TraceID, 41, 64, @on

    exec sp_trace_setevent @TraceID, 41, 66, @on

    -- Set the Filters

    declare @intfilter int

    declare @bigintfilter bigint

    exec sp_trace_setfilter @TraceID, 1, 0, 6, N'%MyView%'

    exec sp_trace_setfilter @TraceID, 1, 0, 1, NULL

    set @intfilter = 45

    exec sp_trace_setfilter @TraceID, 3, 0, 0, @intfilter

    set @intfilter = NULL

    exec sp_trace_setfilter @TraceID, 3, 0, 1, @intfilter

    -- Set the trace status to start

    exec sp_trace_setstatus @TraceID, 1

    -- display trace id for future references

    select TraceID=@TraceID

    goto finish

    error:

    select ErrorCode=@rc

    finish:

    go

    -------------------
    A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
    Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html

  • You might give an Extended Events session a try (assuming you are on 2012).

    Check out this post by Kendra Little on BrentOzar.com:

    http://www.brentozar.com/archive/2013/08/what-queries-are-failing-in-my-sql-server/[/url]

    I've had great success tracking down errors using something very similar.

    Twitter: @SQL_JGood
    Blog: sqljgood.wordpress.com/[/url]

  • Thanks for the tip! I'll try Extended Events.

    - webrunner

    -------------------
    A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
    Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html

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

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