Forums Últimos mensajes - Powered by IBM
 
Tags Palabras claves

SP Traza

16/05/2007 - 17:51 por Penta | Informe spam
Estimados.
Hace un tiempo una persona de una empresa de tuning dejo este SP.
Al ejecutarlo em sale error 12 y no tengo como contactarlo.

1.- Lo ejecuto desde maste con SA



CREATE PROCEDURE SCR_SQLTech_SQLTrace80_START @TrcFolder
nvarchar(255), @TrcMaxSiz bigint, @TrcMinute bigint
AS
begin
DECLARE @TrcPrefix nvarchar( 255)
SELECT @TrcPrefix = replace(@@SERVERNAME,'\','$')
+'.'+replace(replace(replace(convert(varchar(19),getdate(),
121),'-',''),':',''),' ','.')

/
*##################################################################################*/
/
*##################################################################################*/

declare @rc int
declare @TraceID int
declare @option int
declare @tarjetpath nvarchar(128)
declare @stoptime datetime
declare @maxfilesize bigint

SELECT @option = 2
, @tarjetpath = @TrcFolder + '\' + @TrcPrefix
, @stoptime = dateadd(minute,@TrcMinute,getdate())
, @maxfilesize = @TrcMaxSiz

/
*##################################################################################*/

exec @rc = sp_trace_create @TraceID output, 2, @tarjetpath ,
@maxfilesize, @stoptime
if (@rc != 0) goto error


declare @on bit
set @on = 1
/* COLUMNS
1 => TextData
3 => DatabaseID
8 => ClientHostName
10 => ApplicationName
11 => SQLSecurityLoginName
12 => SPID
13 => Duration
14 => StartTime
15 => EndTime
16 => Reads
17 => Writes
18 => CPU
*/

/* 10= RPC:Completed */
exec sp_trace_setevent @TraceID, 10, 1, @on
exec sp_trace_setevent @TraceID, 10, 3, @on
exec sp_trace_setevent @TraceID, 10, 8, @on
exec sp_trace_setevent @TraceID, 10, 10, @on
exec sp_trace_setevent @TraceID, 10, 11, @on
exec sp_trace_setevent @TraceID, 10, 12, @on
exec sp_trace_setevent @TraceID, 10, 13, @on
exec sp_trace_setevent @TraceID, 10, 14, @on
exec sp_trace_setevent @TraceID, 10, 15, @on
exec sp_trace_setevent @TraceID, 10, 16, @on
exec sp_trace_setevent @TraceID, 10, 17, @on
exec sp_trace_setevent @TraceID, 10, 18, @on

/* 12= SQL:BatchCompleted */
exec sp_trace_setevent @TraceID, 12, 1, @on
exec sp_trace_setevent @TraceID, 12, 3, @on
exec sp_trace_setevent @TraceID, 12, 8, @on
exec sp_trace_setevent @TraceID, 12, 10, @on
exec sp_trace_setevent @TraceID, 12, 11, @on
exec sp_trace_setevent @TraceID, 12, 12, @on
exec sp_trace_setevent @TraceID, 12, 13, @on
exec sp_trace_setevent @TraceID, 12, 14, @on
exec sp_trace_setevent @TraceID, 12, 15, @on
exec sp_trace_setevent @TraceID, 12, 16, @on
exec sp_trace_setevent @TraceID, 12, 17, @on
exec sp_trace_setevent @TraceID, 12, 18, @on


declare @intfilter int
declare @bigintfilter bigint

exec sp_trace_setfilter @TraceID, 10, 0, 7, N'SQL Profiler'


exec sp_trace_setstatus @TraceID, 1

select TraceID=@TraceID
goto finish

error:
select ErrorCode=@rc
goto finish

finish:
select traceid
, case property when 1 then 'Trace Options'
when 2 then 'File Name'
when 3 then 'MaxSize (MB)'
when 4 then 'Stop Time'
when 5 then 'Current Trace Status'
else 'Unknown Property'
end as Property
, case property when 1 then (case value when 1 then
'1:TRACE_PRODUCE_ROWSET' when 2 then '2:TRACE_FILE_ROLLOVER' when 4
then '4:SHUTDOWN_ON_ERROR' when 8 then '8:TRACE_PRODUCE_BLACKBOX' else
convert(nvarchar(5),convert(int,value)) + ':Unknown Option' end)
when 5 then value
else Value
end as Value
from ::fn_trace_getinfo(default)

end
 

Leer las respuestas

#1 Isaias
16/05/2007 - 18:16 | Informe spam
Penta

Puedes enviar el TEXTO INTEGRO del mensaje
Saludos
IIslas


"Penta" wrote:

Estimados.
Hace un tiempo una persona de una empresa de tuning dejo este SP.
Al ejecutarlo em sale error 12 y no tengo como contactarlo.

1.- Lo ejecuto desde maste con SA



CREATE PROCEDURE SCR_SQLTech_SQLTrace80_START @TrcFolder
nvarchar(255), @TrcMaxSiz bigint, @TrcMinute bigint
AS
begin
DECLARE @TrcPrefix nvarchar( 255)
SELECT @TrcPrefix = replace(@@SERVERNAME,'\','$')
+'.'+replace(replace(replace(convert(varchar(19),getdate(),
121),'-',''),':',''),' ','.')

/
*##################################################################################*/
/
*##################################################################################*/

declare @rc int
declare @TraceID int
declare @option int
declare @tarjetpath nvarchar(128)
declare @stoptime datetime
declare @maxfilesize bigint

SELECT @option = 2
, @tarjetpath = @TrcFolder + '\' + @TrcPrefix
, @stoptime = dateadd(minute,@TrcMinute,getdate())
, @maxfilesize = @TrcMaxSiz

/
*##################################################################################*/

exec @rc = sp_trace_create @TraceID output, 2, @tarjetpath ,
@maxfilesize, @stoptime
if (@rc != 0) goto error


declare @on bit
set @on = 1
/* COLUMNS
1 => TextData
3 => DatabaseID
8 => ClientHostName
10 => ApplicationName
11 => SQLSecurityLoginName
12 => SPID
13 => Duration
14 => StartTime
15 => EndTime
16 => Reads
17 => Writes
18 => CPU
*/

/* 10= RPC:Completed */
exec sp_trace_setevent @TraceID, 10, 1, @on
exec sp_trace_setevent @TraceID, 10, 3, @on
exec sp_trace_setevent @TraceID, 10, 8, @on
exec sp_trace_setevent @TraceID, 10, 10, @on
exec sp_trace_setevent @TraceID, 10, 11, @on
exec sp_trace_setevent @TraceID, 10, 12, @on
exec sp_trace_setevent @TraceID, 10, 13, @on
exec sp_trace_setevent @TraceID, 10, 14, @on
exec sp_trace_setevent @TraceID, 10, 15, @on
exec sp_trace_setevent @TraceID, 10, 16, @on
exec sp_trace_setevent @TraceID, 10, 17, @on
exec sp_trace_setevent @TraceID, 10, 18, @on

/* 12= SQL:BatchCompleted */
exec sp_trace_setevent @TraceID, 12, 1, @on
exec sp_trace_setevent @TraceID, 12, 3, @on
exec sp_trace_setevent @TraceID, 12, 8, @on
exec sp_trace_setevent @TraceID, 12, 10, @on
exec sp_trace_setevent @TraceID, 12, 11, @on
exec sp_trace_setevent @TraceID, 12, 12, @on
exec sp_trace_setevent @TraceID, 12, 13, @on
exec sp_trace_setevent @TraceID, 12, 14, @on
exec sp_trace_setevent @TraceID, 12, 15, @on
exec sp_trace_setevent @TraceID, 12, 16, @on
exec sp_trace_setevent @TraceID, 12, 17, @on
exec sp_trace_setevent @TraceID, 12, 18, @on


declare @intfilter int
declare @bigintfilter bigint

exec sp_trace_setfilter @TraceID, 10, 0, 7, N'SQL Profiler'


exec sp_trace_setstatus @TraceID, 1

select TraceID=@TraceID
goto finish

error:
select ErrorCode=@rc
goto finish

finish:
select traceid
, case property when 1 then 'Trace Options'
when 2 then 'File Name'
when 3 then 'MaxSize (MB)'
when 4 then 'Stop Time'
when 5 then 'Current Trace Status'
else 'Unknown Property'
end as Property
, case property when 1 then (case value when 1 then
'1:TRACE_PRODUCE_ROWSET' when 2 then '2:TRACE_FILE_ROLLOVER' when 4
then '4:SHUTDOWN_ON_ERROR' when 8 then '8:TRACE_PRODUCE_BLACKBOX' else
convert(nvarchar(5),convert(int,value)) + ':Unknown Option' end)
when 5 then value
else Value
end as Value
from ::fn_trace_getinfo(default)

end


Preguntas similares