日期:2014-05-17 浏览次数:20477 次
exec sp_executesql @stmt=N'begin try
use msdb;
declare @enable int;
select @enable = convert(int, value_in_use) from sys.configurations where name = ''default trace enabled''
if @enable = 1
begin
declare @curr_tracefilename varchar(500);
declare @base_tracefilename varchar(500);
declare @status int;
declare @indx int;
declare @temp_trace table (
Error int
, StartTime datetime
, HostName sysname collate database_default null
, ApplicationName sysname collate database_default null
, LoginName sysname collate database_default null
, Severity int
, DatabaseName sysname collate database_default null
, TextData nvarchar(max) collate database_default
);
select @status=status, @curr_tracefilename=path from sys.traces where is_default = 1 ;
set @curr_tracefilename = reverse(@curr_tracefilename)
select @indx = patindex(''%\%'', @curr_tracefilename)
set @curr_tracefilename = reverse(@curr_tracefilename)
set @base_tracefil