devxlogo

Tip: Enable SQL Server to Run Stored Procedures at Startup

Tip: Enable SQL Server 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'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.

?

Visit the DevX Tip Bank

?

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist