May 7, 2009 at 7:11 am
Hi its only the following bit where I am struggling
exec @rc = sp_trace_create @TraceID output, 0, N'InsertFileNameHere', @maxfilesize, @Datetime
I would like to replace InsertFileNameHere with a @variable, but I can not get it to work.
Please could someone help me with the syntax?
Many thanks
May 7, 2009 at 7:52 am
Declare @filename nvarchar(245),
@rc Int,
@TraceID Int,
@maxfilesize Int,
@DateTime DateTime
Set @filename = 'FilePath\FileName'
Set @maxfilesize = 20
Set @DateTime = DateAdd(Day, 1, GetDate())
exec @rc = sp_trace_create @TraceID output, 0, @filename, @maxfilesize, @Datetime
Select @TraceID as traceid
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
May 7, 2009 at 7:54 am
Ive got a stored procedure which does it; is this what you want?
--we want the current trace folder
declare @path nvarchar(256)
--ie c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG
SELECT @path = REVERSE(SUBSTRING(REVERSE(path),CHARINDEX('\',REVERSE(path)),256)) FROM sys.traces WHERE is_default = 1
SET @path = @path + N'MyDMLtrace' --system appends .trc automatically for the filename
--create the trace
exec sp_trace_create @traceidout output, @maxRolloverFiles, @path, @maxfilesize, NULL
Lowell
May 7, 2009 at 10:14 am
Great help people. Many thanks
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply