Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Schedule SQl ServerTrace

Author  Topic 

reddy_vam
Starting Member

43 Posts

Posted - 2009-07-07 : 14:33:02
I have schedule a trace to run daily, but it overwriting the previous day files daily but I don’t want to overwrite these files daily as I want to save all the trace files. And also I am not sure how to pass @datetime value dynamically, everyday I am manually updating the @datetime value.
Can somebody help me to modify the script?

declare @DateTime datetime
declare @ObjectLabel nvarchar(256)

set @DateTime = '2009-07-07 04:00:00.000'
--set @maxfilesize = 50
SET @ObjectLabel = 'C:\Trace\Trace_' + CONVERT(CHAR(8), GETDATE(), 112)

exec @rc = sp_trace_create @TraceID output, 0, @ObjectLabel, @maxfilesize, @Datetime

Thanks,
Vamshi

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-07-08 : 23:22:59
how about set @datetime = getdate()

you need to use the @trace_file paramater to specify the filename -- which it looks like you're storing in your @ObjectLabel variable. See http://msdn.microsoft.com/en-us/library/ms190362.aspx for proper syntax
Go to Top of Page

senfriends2008
Starting Member

5 Posts

Posted - 2009-07-10 : 10:10:40
how to find out current running jobs

Thanks
K.senthilkumat
Go to Top of Page
   

- Advertisement -