Are there any special steps necessary to prevent data corruption when restarting a server hosting an MS SQL Server instance?
For example, I recently encountered the recommendation of stopping the SQL service manually. My understanding is that this is handled by the Windows shutdown
process.
I'm sure there are a zillion steps which individual people may recommend, like that I just mentioned, but I'd like to avoid repeating obsolete or superstitious practices. Are there any recommendations from Microsoft, or widespread industry standards?
This question relates to the short-term procedure of rebooting a machine. There's another question regarding the long-term procedure of ensuring that a machine is unused, before taking it down permanently.
Best Answer
You don't have to be fancy/worried or scared when you are restarting sql server.
Just make sure that you dont have any long running transactions. Best is to restart sql server using console or shutdown command during a low/minimum activity period also called maintenance window to minimize impact on your business.
If you have any DR setup and you dont want to be down, then best is to failover and then restart the passive or secondary node.
Clean Shutdown SQL Server occurs in below scenarios :
In above all situations, sql server cleanly shutsdown all its databases and then terminates the service which involves commiting or rolling back all the transactions, writing all dirty pages to disk and then writing an entry into transaction log.
Improper shutdown of sql server :
SQL Server will always try to do a clean shutdown ...unless you do something improper as stated above.
Some really good reading links on what happens behind the scenes during recovery phase :