Stored procedure execution on SQL Server startup:
I have studied a very interesting topic in SQL Server and wish to blog the same in my site.
Scenario:
On each SQL Server database startup, I need to execute a procedure in my database. It's a very basicscenario in all places.
Solution:
For this, SQL Server is providing an option of using a system stored procedure sp_procoption
create procedure Venkatesan_Insert_Procedure
as
begin
insert into venkat1(id,val) values (5,'F')
end
EXEC sp_procoption @ProcName = 'Venkatesan_Insert_Procedure',@OptionName = 'startup',@OptionValue = 'true'
Now, your stored procedure is set as a initial startup which will execute on DB start.
Cheers,
Venkatesan Prabu .J