SQL SERVER – Start Services or Stop Services with PowerShell – Answer to Question

Earlier I asked a very interesting question related to Powershell and T-SQL command. Read my earlier blog post SQL SERVER – Start Services or Stop Services with PowerShell – Question to Readers?.

Here is the question which I asked – Stop-Services ‘mysqlserver’ in powershell is equivalent to Shutdown or Shutdown With Nowait in T-SQL?

Well, I asked this question because I really had no idea about the answer. However, my personal friend and Powershell Guru Laerte Junior immediately took the challenge to find answers to this question. He comes up with a fantastic explanation of the answer with proper findings and experiments.

Laerte did multiple test to figure out the answer to the question. He used traceflags 2592 and 3605 and to log the status of the checkpoint to the SQL Server log files. I strongly encouraged everyone to read his blog post as it will absolutely teach you something new. Here is the link to his blog post: Stop-Service is like the T-SQL Shutdown or Shutdown with Nowait ?

After doing multiple test Laerte proves that STOP-SERVICE -force is like to use SHUTDOWN, performing the checkpoint in each database. Indeed a correct answer.

I did not know this before and I learned – Thanks Laerte. Did you know about this one? If you have learned this today as well, please leave a comment. The first step of learning anything is to accept we do the topic. The next step is to learn it.

Reference: Pinal Dave (https://blog.sqlauthority.com)

Previous Post
SQL SERVER – Start Services or Stop Services with PowerShell – Question to Readers?
Next Post
MySQL – Locate the Configuration File – my.ini or my.cnf on Windows Platform

Related Posts

4 Comments. Leave new

  • Laerte Junior
    January 7, 2014 1:43 pm

    Thanks for the mention my good friend. It was an excellent question and I did not know the answer too. I’ve learned something new as well

  • Laerte Junior
    January 7, 2014 2:11 pm

    Reblogged this on $hell Your Experience !!! and commented:
    I ´m honored to have my name again at sqlauthority.com. Thanks a lot my good friend :)

  • pavansantoshvuppala
    January 7, 2014 2:25 pm

    Hi , Laerte used the traceflags 3502/3605 , here it is mentioned 2592/3605 , can we trace with 2592 also ?

  • Hi Pinal,

    When i trying to execute the Powershell script using Powershell ISE it is working ( ie. correctly looping thru the serverlist provided in the text file) but when the same PS script is being called using SQL Agent Step no looping take place(ie. able to get the info related to only one server , not getting the other server details menioned in the same text file)

    so could you please suggest the needful.



Leave a ReplyCancel reply

Exit mobile version