我使用下面的查询来获取信息,但是,TextData列为空:
select top 10 *
from fn_trace_gettable('d:\data\myTrace.trc', 0)
我还使用SQL Server 2017 Profiler打开跟踪文件,但遇到相同的问题(TextData
列为空白。)
这是设置跟踪的查询:
-- Create a Queue
declare @rc int
declare @TraceID int
declare @maxfilesize bigint
declare @traceoptions int
declare @stoptime datetime
set @traceoptions = 0
set @maxfilesize = 6
set @stoptime = DATEADD(hh, 1, GETDATE())
-- Create the trace with the name of the output file - .trc extension is added to filename
exec @rc = sp_trace_create @TraceID output, @traceoptions, N'D:\data\test924', @maxfilesize, @stoptime
if (@rc != 0) goto error
-- Set the events
declare @on bit
set @on = 1
-- SQL:BatchCompleted events
exec sp_trace_setevent @TraceID, 42, 15, @on
exec sp_trace_setevent @TraceID, 42, 16, @on
exec sp_trace_setevent @TraceID, 42, 1, @on
exec sp_trace_setevent @TraceID, 42, 9, @on
exec sp_trace_setevent @TraceID, 42, 17, @on
exec sp_trace_setevent @TraceID, 42, 6, @on
exec sp_trace_setevent @TraceID, 42, 10, @on
exec sp_trace_setevent @TraceID, 42, 14, @on
exec sp_trace_setevent @TraceID, 42, 18, @on
exec sp_trace_setevent @TraceID, 42, 11, @on
exec sp_trace_setevent @TraceID, 42, 12, @on
exec sp_trace_setevent @TraceID, 42, 13, @on
-- SQL:BatchStarting events
exec sp_trace_setevent @TraceID, 43, 15, @on
exec sp_trace_setevent @TraceID, 43, 16, @on
exec sp_trace_setevent @TraceID, 43, 1, @on
exec sp_trace_setevent @TraceID, 43, 9, @on
exec sp_trace_setevent @TraceID, 43, 17, @on
exec sp_trace_setevent @TraceID, 43, 6, @on
exec sp_trace_setevent @TraceID, 43, 10, @on
exec sp_trace_setevent @TraceID, 43, 14, @on
exec sp_trace_setevent @TraceID, 43, 18, @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
-- Filter out the SQL Profiler events
exec sp_trace_setfilter @TraceID, 1, 0, 6, N'%SaveVerifiedDomains%'
-- exec sp_trace_setfilter @TraceID, 1, 0, 6, N'%SaveDomainProvisioningRequest%'
-- 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