For a Stored Procedure to be eligible to be executed when SQL Server starts, the stored procedure must be in the "master" database and cannot contain INPUT or OUTPUT parameters.
The sp_procoption system stored procedure is useful in setting the Stored Procedure for autoexecution - i.e it runs every time SQL Server service is started.
Here's how to execute a Stored Procedure when SQL Server starts
EXEC sp_procoption 'usp_SomeProcForStart', 'startup', 'true'
To disable the stored procedure again
EXEC sp_procoption 'usp_SomeProcForStart', 'startup', 'false'
For a Stored Procedure to be eligible to be executed when SQL Server starts, the stored procedure must be in the ‘master’ database and cannot contain INPUT or OUTPUT parameters.
The sp_procoption system stored procedure is useful in setting the Stored Procedure for autoexecution - i.e it runs every time SQL Server service is started.
Here's how to execute a Stored Procedure when SQL Server starts
EXEC sp_procoption 'usp_SomeProcForStart', 'startup', 'true'
To disable the stored procedure again
EXEC sp_procoption 'usp_SomeProcForStart', 'startup', 'false'
For a Stored Procedure to be eligible to be executed when SQL Server starts, the stored procedure must be in the ‘master’ database and cannot contain INPUT or OUTPUT parameters.
Comments
Post a Comment