• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

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

发布: 2007-7-02 11:08 | 作者: admin | 来源: | 查看: 14次 | 进入软件测试论坛讨论

领测软件测试网
/*-- 下面是我用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 Queuedeclare @rc intdeclare @TraceID intdeclare @maxfilesize bigintset @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 eventsdeclare @on bitset @on = 1exec sp_trace_setevent @TraceID, 12, 1, @onexec sp_trace_setevent @TraceID, 12, 12, @onexec sp_trace_setevent @TraceID, 12, 14, @on

-- Set the Filtersdeclare @intfilter intdeclare @bigintfilter bigint

exec sp_trace_setfilter @TraceID, 10, 0, 7, N@#SQL Profiler@#set @intfilter = 100exec sp_trace_setfilter @TraceID, 22, 0, 4, @intfilter

set @intfilter = 1exec sp_trace_setfilter @TraceID, 23, 1, 0, @intfilter

exec sp_trace_setfilter @TraceID, 35, 1, 6, N@#pubs@#

-- Set the trace status to startexec sp_trace_setstatus @TraceID, 1

-- display trace id for future referencesselect TraceID=@TraceIDgoto finish

error: select ErrorCode=@rc

finish: go

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网