February 8, 2007 at 12:37 pm
Hello, I'm new here. I have a question concerning the generated trace file. Is the a way to modified the trace file name to be the name of the server.
I want to use the servername as the name of the trace file. Does any one have any suggestions? How do you use a variable in place of the N' notation
/****************************************************/
/* Created by: SQL Profiler */
/* Date: 01/30/2007 04:00:06 PM */
/****************************************************/
-- Create a Queue
declare @rc int
declare @TraceID int
declare @maxfilesize bigint
declare @DateTime datetime
set @DateTime = (SELECT DATEADD(mi, 1, getdate()) )
DECLARE @FNAME NCHAR(30)
DECLARE @servername NCHAR(30)
set @servername = @@servername
SET @FNAME = 'C:\' + @servername
PRINT @FNAME
-- 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'+ @FNAME', @maxfilesize, @Datetime
if (@rc != 0) goto error
February 11, 2007 at 3:52 am
You don't need N' becuase you already declared fname as nchar...
-- Create a Queue
declare @rc int
declare @TraceID int
declare @maxfilesize bigint
declare @DateTime datetime
set @DateTime = (SELECT DATEADD(mi, 1, getdate()) )
DECLARE @FNAME NCHAR(30)
DECLARE @servername NVarchar(30)
SET @FNAME = 'C:\Trace_' + @@servername
set @maxfilesize = 100 -- 100 MB
select @FNAME
PRINT @FNAME
-- I changed second parameter from 0 to 2 becuase 2 will rollover see BOL...
exec @rc = sp_trace_create @TraceID output, 2, @FNAME , @maxfilesize, @Datetime
if (@rc != 0) goto error
MohammedU
Microsoft SQL Server MVP
February 11, 2007 at 6:59 pm
Thanks for your help Mohammed
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply