用SQL语句来建立跟踪的问题

本文探讨了使用SQL Server 事件探察器时遇到的问题,包括跟踪不生成数据、ObjectType设置疑问、特定语句跟踪配置及跟踪结果保存等关键技术点。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
下面是我用 SQL的事件探察器设置跟踪,并生成的 SQL脚本
 现在有几个 问题:
 
1.这个跟踪不会产生数据,用:
  select * from ::fn_trace_getinfo(1)
 可以看到状态是在运行,但 c:/test.trc 始终是空文件 
 
2.在事件探察器中设置筛选时,ObjectType 的说明是对应sysobjects 表的 type 列,该列是字符型,但我输入字符时要求是数字,这个数字从那里查?
 
 3.如果只产生对 insert,update,delete 语句成功的跟踪事件应该如何设置呢? 在 事件探察器 中无相关设置,用语句设置的话只找到事件号 28, 在执行 SELECT、INSERT 或 UPDATE 语句之前发生
 
 4.用事件探察器建立的跟踪,可以将跟踪结果保存到表中,但我下面生成的 SQL脚本却不支持这个功能
--*/
/****************************************************/
/* Created by:  SQL Profiler                         */
/* Date: 2004/06/19  16:50:05         */
/****************************************************/

-- Create a Queue
declare @rc int
declare @TraceID int
declare @maxfilesize bigint
set @maxfilesize = 5 
-- 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, 0, N’c:/test’, @maxfilesize, NULL 
if (@rc != 0) goto error
-- Client side File and Table cannot be scripted
-- Writing to a table is not supported through the SP’s
-- Set the events
declare @on bit
set @on = 1
exec sp_trace_setevent @TraceID, 12, 1, @on
exec sp_trace_setevent @TraceID, 12, 12, @on
exec sp_trace_setevent @TraceID, 12, 14, @on

-- Set the Filters
declare @intfilter int
declare @bigintfilter bigint
exec sp_trace_setfilter @TraceID, 10, 0, 7, N’ SQL Profiler’
set @intfilter = 100
exec sp_trace_setfilter @TraceID, 22, 0, 4, @intfilter
set @intfilter = 1
exec sp_trace_setfilter @TraceID, 23, 1, 0, @intfilter
exec sp_trace_setfilter @TraceID, 35, 1, 6, N’pubs’ 1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值