This question already has an answer here:

I'm running the following SQL on SQL Server 2000:

exec sp_trace_create @options = 2,
         @tracefile = N'h:\\trace.trc',
         @filecount = 2

and am getting the following error and can't understand why:

Procedure expects parameter '@tracefile' of type 'nvarchar(128)'

If I pass all of the parameters in like so:

declare @id int

exec sp_trace_create @id output,
         @options = 2,
         @tracefile = N'h:\\trace.trc',
         @filecount = 2,
         @maxfilesize = 5,
         @stoptime = '2013-8-15'

I get the error:

Procedure or function sp_trace_create has too many arguments specified.

marked as duplicate by Paul White, dezso, Nick Chammas, StanleyJohns, Mark Storey-Smith Jul 16 '13 at 11:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Martin Smith has answered https://dba.stackexchange.com/a/24728/8783

This will work :

DECLARE @new_trace_id INT;

EXECUTE master.dbo.sp_trace_create
  @someinteger = @new_trace_id OUTPUT,
  @someinteger = 0,
  @someinteger = N'C:\trace\TestTrace.trc';

  -- get trace status 
  SELECT * FROM ::fn_trace_getinfo(NULL)
  -- stop trace
  EXEC sp_trace_setstatus @traceid = 1 -- CHANGE THIS AS PER YOUR TRACE id
                    , @status = 0  
  -- delete trace
  EXEC sp_trace_setstatus @traceid = 1  -- CHANGE THIS AS PER YOUR TRACE id
                    , @status = 2

I'm not sure why but it appears that sp_trace_create requires all parameters be passed. This includes the @traceid parameter. The error is definitely misleading. Add the @traceid parameter and the next error you get will be for @maxfilesize.

Not the answer you're looking for? Browse other questions tagged or ask your own question.