ehsan
ehsan

Reputation: 787

automatically restart sql server after rebuild index

i want to automatically restart sql server after nightly rebuild index (in a job) to free memory.

any solution?

Upvotes: 0

Views: 2004

Answers (3)

WaitForPete
WaitForPete

Reputation: 467

It looks like you may be seeing poor performance from SQL Server as the server has stolen all the RAM from the Operating Systyem. Check that the total memory available to all instances of SQL server on your server leaves enough for the OS to work in RAM (4Gb or so).

Upvotes: 0

Quassnoi
Quassnoi

Reputation: 425361

A direct answer to your question would be to write a batch job:

net stop MSSQLSERVER
net start MSSQLSERVER

and schedule it in Windows Scheduler.

However, I wonder:

  1. Why do you need a nightly index rebuild at all?
  2. Which memory you want to free and why? DBCC DROPCLEANBUFFERS will purge the buffer pool which is the only thing that will be seriously affected, but why would you want to clean it?

Upvotes: 2

Donnie
Donnie

Reputation: 46913

You do not want to restart SQL Server to free memory. It is using memory to improve performance. Restarting it merely forces it to recache everything AGAIN at the cost of query performance.

Upvotes: 3

Related Questions