Re: Setting up Trace in SQL

From: Andrew J. Kelly (sqlmvpnooospam_at_shadhawk.com)
Date: 11/22/03


Date: Sat, 22 Nov 2003 13:18:08 -0500

You might find a tool such as Entegra from www.lumigent.com a much better
alternative than running profiler traces. While it does cost some money
it's features and ease of use are unsurpassed. To answer your question
though you can do something like this:

DECLARE @File NVARCHAR(100)
SET @File = N'D:\mssql\audit\AuditFile' + CONVERT(NVARCHAR(8),GETDATE(),112)

exec sp_trace_create @TraceID output, 2, @File

-- 
Andrew J. Kelly
SQL Server MVP
"Audrey L" <robwhitz@yahoo.com> wrote in message
news:006d01c3b114$f2051ef0$a101280a@phx.gbl...
> Hi Andrew,
>
> The company has a policy and states that we have to audit
> our databases.  That's why I have created a stored
> procedure to handle this.
>
> This is the command that executes the audit at every
> startup.
> **exec sp_procoption N'usp_SQLAudit', N'startup', N'true'**
>
> Within the same SP, it will output the audit info to a
> file.  It will rollover each time it reaches 5MB, and the
> new filename will be AuditFile_1, AuditFile_2 and so forth.
> **exec sp_trace_create @TraceID output, 2,
> N'D:\mssql\audit\AuditFile'**
>
> With the above command, how can I specify a unique
> filename?  It would be pretty cool if I can prefix with
> yyyymmdd_AuditFile.
>
> Thanks,
> Audrey
>
> >-----Original Message-----
> >Although I don't usually set up traces to start when the
> db restarts I don't
> >know why the presence of an existing file would be an
> issue.  How exactly
> >are you starting the trace?   Can you simply specify a
> name for the file
> >that would be unique each time it runs?
> >
> >-- 
> >
> >Andrew J. Kelly
> >SQL Server MVP
> >
> >
> ><anonymous@discussions.microsoft.com> wrote in message
> >news:057a01c3b0ba$16ffbbd0$a401280a@phx.gbl...
> >> I agree.  But supposed if I were to re-start the DB, the
> >> audit does not kick off at all coz the trace files still
> >> exist in the system.
> >>
> >> In that case, I would need to move the trace files out
> >> from the designated directory.  Where and how can I do
> >> this?  Ot typically, how does the other DBA achieve
> this?
> >>
> >> >-----Original Message-----
> >> >There is no way to append it that I know of.  What
> >> benefit would this give
> >> >you?
> >> >
> >> >-- 
> >> >
> >> >Andrew J. Kelly
> >> >SQL Server MVP
> >> >
> >> >
> >> >"Audrey L" <robwhitz@yahoo.com> wrote in message
> >> >news:07c601c3afe8$20a4ca90$a101280a@phx.gbl...
> >> >> Hi,
> >> >>
> >> >> I have configured SQL Server to activate a trace at
> >> every
> >> >> server startup.  The main objective is to audit all
> >> >> critical events on the DB.
> >> >>
> >> >> As the maxsize of the trace file is 5MB, I managed to
> >> >> configure it to perform a rollover whenever the
> >> threshold
> >> >> is reached.
> >> >>
> >> >> One thing that I would like to clarify is: - Suppose
> the
> >> >> trace file 'TraceA.trc' already exists in the
> directory.
> >> >> The DB was re-started.  New records are not appended
> to
> >> >> the trace file at all.  Is there a way to activate
> this?
> >> >> Or is there any workaround?
> >> >>
> >> >> Would appreciate advice.  Thanks ...
> >> >
> >> >
> >> >.
> >> >
> >
> >
> >.
> >


Relevant Pages

  • [ANNOUNCE][PATCH 0 of 4] zedtrace, a general-purpose binary tracer
    ... It's called zedtrace and is ... Trace events from different subsystems ... This results in a set of per-cpu trace files in the current directory: ... script as native param variables. ...
    (Linux-Kernel)
  • Re: CLOB updates using ADODB not showing in trace file
    ... take the money and provide extended support, then I feel perfectly within rights to post a question ... SQL_TRACE is set to TRUE at the database level. ... Initially trace was being enabled via a logon database trigger, but since we noticed the problem I ... we have searched all the trace files ...
    (comp.databases.oracle.misc)
  • Re: urgent problem that I want to have a comment about
    ... We get exactly the same problem when we build the MFC dll in debug mode. ... You have not said what kind of trace facility you are using, and therefore, there is no ... If these "really good trace files" allocate memory, ...
    (microsoft.public.vc.mfc)
  • Re: WSE Authentication problem when calling from a dll
    ... You are not being able to see the trace files on the web service side ... So I have the web page call a dll which calls the proxy. ... password that I want to use in the wse policy wizard on the web page ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Re: Auditing
    ... If you use the feature in Enterprise Manager for Audit ... Profiler or a server trace. ... trace file. ... Stored Procedure to Create a SQL Server 2000 Blackbox ...
    (microsoft.public.sqlserver.security)