Tags

, ,


We can mark a Stored procedure to run when SQL server starts. For this to happen, we need to do the following:

  1. Create the Stored Procedure in the Master database
  2. We have to set the Startup flag for this particular Stored procedure.

For example, I want Stored Procedure named “usp_startup_log” to run whenever SQL Server starts. Here is how you do this:

exec sp_procoption N’usp_startup_log’, ‘startup’, ‘1’

Now if we want to list all the Stored procedure that are marked to run when SQL Server starts, then we can use below query :

SELECT name,create_date
FROM sys.procedures
WHERE is_auto_executed = 1

Advertisements