Databases Reference
In-Depth Information
--Add EndTime column to LogFileAutoGrow event.
EXECUTE sp_trace_setevent
@traceid = @TraceID
,@eventid = @Event_LogFileAutoGrow
,@columnid = @DataColumn_EndTime
,@on = @On
--Start the trace. Status 1 corresponds to START.
EXECUTE sp_trace_setstatus
@traceid = @TraceID
,@status = 1
END TRY
BEGIN CATCH
PRINT 'An error occurred while creating trace.'
END CATCH
END
GO
It is possible that the stored procedure sp_trace_create may
fail if the windows account under which the SQL Server Service
is running has no write permission on the directory where the
trace file is created. If this is the case, then you will need to assign
proper permissions to the login account so that it can write to the
specified directory.
3.
By executing the following query and observing the result set, make sure that the
trace has been created successfully. This query should return a record for the trace
that we created:
--Verify the trace has been created.
SELECT * FROM sys.traces
GO
4.
The previous query will give you the list of traces that are currently running on
the system. You should see your newly created trace listed in the result set of the
previous query. If the trace could be created successfully, execute the following T-SQL
script to create a sample database and insert one million records:
--Creating Sample Database keeping Filegrowth Size
--to 1 MB for Data and Log file.
CREATE DATABASE [SampeDBForTrace] ON PRIMARY
(
NAME = N'SampeDB'
,FILENAME = N'C:\MyTraces\SampeDBForTrace_Data.mdf'
,SIZE = 2048KB , FILEGROWTH = 1024KB
)
 
Search WWH ::




Custom Search