Create schedule Restart SQL Server

 If you want to schedule the restart of SQL Server or Windows Server on a regular basis, you can use the Windows Task Scheduler. Here's a general guide on how to create a scheduled task for restarting SQL Server and Windows Server:


Schedule SQL Server Restart:

Open Task Scheduler:


Press Win + R to open the Run dialog.

Type taskschd.msc and press Enter.

Create a Basic Task:


In the Task Scheduler, select "Create Basic Task" from the right-hand actions pane.

Name and Description:


Provide a name and description for your task. Click Next.

Trigger Configuration:


Choose the trigger type (Daily, Weekly, Monthly) based on when you want the SQL Server to restart.

Set the start date and time. Click Next.

Action Selection:


Choose "Start a program" as the action. Click Next.

Program/Script:


Browse and select the SQL Server service executable. The default path is typically C:\Program Files\Microsoft SQL Server\MSSQL<Instance>\MSSQL\Binn\sqlservr.exe.

Add the following parameters: -s<InstanceName> -m -f. Replace <InstanceName> with your actual SQL Server instance name.

Click Next.

Summary:


Review your settings and click Finish.



powershell.exe Restart-Service -Force MSSQLSERVER

Comments

Popular posts from this blog

Hướng dẫn tạo Users, OU và phân quyền quản lý OU trên Windows

Import JSON data into SQL Server

Data Import Best Practices in Power BI