Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

up vote 3 down vote accepted

Martin Smith has answered

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
share|improve this answer

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.

share|improve this answer
Thanks. I've tried that and updated my question accordingly – rhughes Jul 15 '13 at 18:45
SQL 2000 doesn't have an @filecount parameter. That's not until SQL 2005 – Kenneth Fisher Jul 15 '13 at 18:49
@rhughes This is the link to what Kenneth mentioned… – Kin Jul 15 '13 at 19:02
Only the first three parameters are mandatory. There are six in total but as it only accepts positional parameters all preceding ones must be supplied. – Martin Smith Jul 16 '13 at 6:37
The OP is using SQL 2000. The 6th parameter was not added until SQL 2005. – Kenneth Fisher Jul 16 '13 at 13:06

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