Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run script on DB Startup 1

Status
Not open for further replies.

ousoonerjoe

Programmer
Jun 12, 2007
925
US
I must not be putting in the right key words to Google. I have a simple DBCC command I want to run every time the server/service is restarted. The Maintenance Plans do not support an "On Start Up" option for execution times.

Does anyone know how to accomplish this? Is it possible? I appreciate any and all suggestions you may have.

Thank you.

--------------------------------------------------
“Crash programs fail because they are based on the theory that, with nine women pregnant, you can get a baby a month.” --Wernher von Braun
--------------------------------------------------
 
There is a system stored procedure called sp_procoption that will allow this. However, I think this is for 'database startup' more so than system/service startup. You must run this command in the master database which starts up when the SQL Server service starts, so the net effect should be the same.


I'm curious though... what DBCC command are you trying to run?

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
SQL Agent jobs can also be run at the time SQL Agent starts, which is usually when SQL Server starts.
 
George, Thank you. That's close enough for what I need.

Code:
DBCC TRACEON (3605,1204,1222,-1)

It's a simple little setting that enables the DeadLock information to be reported. I then have a job that dumps that info to an email and sends it to us. In fact, I got it from SqlServerCentral.com here. It's been an immense help in getting this old Unisys conversion project cleaned up. But it seems that the TRACEON switch resets to default if the server/service is restarted.

--------------------------------------------------
“Crash programs fail because they are based on the theory that, with nine women pregnant, you can get a baby a month.” --Wernher von Braun
--------------------------------------------------
 
Ah... I see.

I usually do this with the -T start up parameter.

On the server, click Start -> run
Type services.msc
Click OK
Scroll down to SQL Server.
Right click -> Properties

At the bottom of the general tab, there is a text box for "Start Parameters"

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Well, they (NetAdmins) have that locked out. So I used the sp_procoption you mentioned previously until they decide to get around to doing it.

George, thank you greatly for the assist.

--------------------------------------------------
“Crash programs fail because they are based on the theory that, with nine women pregnant, you can get a baby a month.” --Wernher von Braun
--------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top