I'm running maintenance plans at night on my SQL Server 2008 database for reorganizing the indexes and shrinking the database. While this plan is running a windows service that I built that queries the DB keeps failing with timeouts.

How can I stop the Windows Service from within the Maintenance Plan?

link|improve this question

feedback

1 Answer

up vote 1 down vote accepted

you can use the xp_cmdshell SP to issue a net stop <service_name> then a net start <service_name>

link|improve this answer
Thanks Zypher, I was going this route, but I'm getting a System error 5 has occurred. Access Denied. Do you know in which user context do the Maintenance Plans run as? – jstawski Jan 8 '10 at 0:59
You might need to set the proxy account, or strait out enable the SP See the remarks section (about halfway down) of my technet link for the howto – Zypher Jan 8 '10 at 1:05
do you know which security rights I should grant the user to be able to execute the net command? Maybe I should open a new question for that – jstawski Jan 8 '10 at 1:16
You're options are 1) (local | domain) admin or 2) Grant a user permissions by following this KB support.microsoft.com/kb/325349 – Zypher Jan 8 '10 at 1:29
this is very weird. Since I can't get this to work. I added the user running the SQL Server Service as part of the admin group and when I run the xp_cmdshell I still get Access is denied. What could I be doing wrong? – jstawski Jan 8 '10 at 3:30
show 1 more comment
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.