Executing Stored Procedures Automatically at SQL Server Startup : sp_procoption « System Functions « SQL Server / T-SQL Tutorial






3>
4> USE MASTER
5> GO
Changed database context to 'master'.
1>
2> CREATE TABLE dbo.SQLStartupLog
3> (SQLStartupLogID int IDENTITY(1,1) NOT NULL PRIMARY KEY,
4> StartupDateTime datetime NOT NULL)
5> GO
1>
2> CREATE PROCEDURE dbo.usp_INS_TrackSQLStartups
3> AS
4> INSERT dbo.SQLStartupLog
5> (StartupDateTime)
6> VALUES (GETDATE())
7> GO
1>
2> EXEC sp_procoption @ProcName = 'usp_INS_TrackSQLStartups',
3> @OptionName = 'startup',
4> @OptionValue = 'true'
5>
6> GO
1>
2> EXEC sp_procoption @ProcName = 'usp_INS_TrackSQLStartups',
3> @OptionName = 'startup',
4> @OptionValue = 'false'
5> GO
1>
2> drop table dbo.SQLStartupLog
3> GO
1> drop procedure dbo.usp_INS_TrackSQLStartups
2> GO
1>








25.50.sp_procoption
25.50.1.Executing Stored Procedures Automatically at SQL Server Startup