×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Enable SQL Server to Run Stored Procedures at Server Startup
 

Submitted by: Hannes du Preez(ojdupreez1978@gmail.com)

Thursday May 3rd 2018 by Hannes du Preez

Language: SQL, Expertise: Intermediate - Learn the two-step process required to run stored procedures at startup.

In order to execute a Stored Procedure when SQL Server starts, you first need to enable scanning for Startup Procedures with the following code:

EXEC sys.sp_configure N'scan for startup procs', N'1'
GO
RECONFIGURE WITH OVERRIDE
GO

Once you have configured your server to run Stored Procedures on startup, you have to enable the desired Stored Procedure to run at startup:

USE master
GO
EXEC SP_PROCOPTION ProcToRunAtEachStartup, 'STARTUP', 'ON'
GO

Now, each time your server is started the above stored procedure (named ProcToRunAtEachStartup - you can name yours anything you like) will run.

Home
Mobile Site | Full Site
Copyright 2018 © QuinStreet Inc. All Rights Reserved