How can I get automise to run an SQL query? I am wanting to automate this task so that I don't have to physically do it every morning.
Here is an example of the first few lines.
--Verify Trace is Running (if no records returned, trace is not running)
SELECT * FROM :: fn_trace_getinfo(0)
DECLARE @TraceID INT
DECLARE @MaxSize bigint
DECLARE @StopLogTime datetime
SET @MaxSize = 500
--STEP 1 - Change the Log Stop Time (next day)
SET @StopLogTime = '2008-09-24 22:00:00'
--STEP 2 - Modify the Trace Log File Output Name
EXECUTE sp_trace_create @TraceID output,
@options = 2, --//rollover the file when max size is reached
@tracefile = N'E:\Unapen\Task Centre\SQL Traces\Lock_Timeout_Monitor_20080924', --//trace file name
@maxfilesize = @MaxSize, --//maximum file size
@stoptime = @StopLogTime