SQL Server/T-SQL Tutorial/System Functions/sp procoption

Материал из SQL эксперт
Перейти к: навигация, поиск

Executing Stored Procedures Automatically at SQL Server Startup

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>