博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
用sql语句来建立跟踪的问题(转)
阅读量:2495 次
发布时间:2019-05-11

本文共 2031 字,大约阅读时间需要 6 分钟。

下面是我用sql的事件探察器设置跟踪,并生成的sql脚本
现在有几个问题:
1.这个跟踪不会产生数据,用:
select * from ::fn_trace_getinfo(1)
可以看到状态是在运行,但 c: est.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:myfoldermytrace. 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: est’, @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’
-- 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

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10294527/viewspace-122608/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10294527/viewspace-122608/

你可能感兴趣的文章
学习笔记整理之模式化方法
查看>>
filter-mutate过滤插件
查看>>
jquery JSON的解析方式
查看>>
LeetCode Reverse Integer
查看>>
[SPOJ DQUERY] D-query(树状数组,离线)
查看>>
Cannot open include file: jni.h: No such file or directory解决方法
查看>>
HDU-水饺基情 二维树状数组
查看>>
visual studio 安装Entity framework失败
查看>>
Android 面向切面编程-aspjectj应用
查看>>
测试对bug如何分析和定位
查看>>
c/c++学习书籍
查看>>
python应用-爬取猫眼电影top100
查看>>
HC-05蓝牙模块基本使用
查看>>
phper必知必会之类库自动加载的七种方式(三)
查看>>
ansible模块介绍
查看>>
NOIP201307货车运输
查看>>
BZOJ3670: [Noi2014]动物园
查看>>
[转]Java反射机制详解
查看>>
保护程序猿滴眼睛-----修改VS 2008 编辑器颜色 (&&修改 chrome浏览器的背景色)
查看>>
动态规划 背包九讲的实现。
查看>>