SQL Server : DefaultJob on ServerRestart or Start

73 Views Asked by At

I want to give our IT a hand regarding the creation of a DefaultJob, that executes himself every server restart or start (Windows SQL Server 2012)

There is a trace that always activates himself after the server restarts or starts (after a hard shutdown or updates).

Basically I want to execute the following query (deactivate the Trace with the ID 1) automatically over a DefaultJob (a Job in the SQL Server Agent):

exec sp_trace_setstatus 1,0

Before executing it, I want to check if the trace with the ID 1 is active, if yes, then execute the query, if not, do nothing.

Any help would be much appreciated.

If you guys have questions, just ask... :-)

Thanks a lot in advance. Cheers!

0

There are 0 best solutions below