Enable SQL Server to Run Stored Procedures at Server 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'GORECONFIGURE WITH OVERRIDEGO

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 masterGOEXEC 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.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Related Posts