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 basic scenario in all places.
Solution:
For this, SQL Server is providing an option of using a system stored procedure sp_procoption
-- Am creating a table
create table venkat1(id int, val varchar(10))
-- 'Am creating a procedure to insert a record in a table venkat1
create procedure Venkatesan_Insert_Procedure
as
begin
insert into venkat1(id,val) values (5,'F')
end
-- Am setting the sp_procoption for my procedure with the option name as "Startup" and option value as "True"
EXEC sp_procoption @ProcName = 'Venkatesan_Insert_Procedure',@OptionName = 'startup',@OptionValue = 'true'

select * from venkat1

Thanks and Regards,
Venkatesan Prabu .J
No comments:
Post a Comment