Error using sp_trace_create with parameters 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.
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  
  go 
  -- delete trace
  EXEC sp_trace_setstatus @traceid = 1  -- CHANGE THIS AS PER YOUR TRACE id
                    , @status = 2