---
title: "Clear-DbaWaitStatistics"
description: "Resets SQL Server wait statistics to establish a clean monitoring baseline"
url: "https://dbatools.io/Clear-DbaWaitStatistics/"
availability: "Windows, Linux, macOS"
tags: ["Diagnostic", "WaitStats", "Waits"]
author: "Chrissy LeMaire (@cl)"
source: "https://github.com/dataplat/dbatools/blob/master/public/Clear-DbaWaitStatistics.ps1"
last_updated: "2024-01-01"
---

# Clear-DbaWaitStatistics

## Synopsis

Resets SQL Server wait statistics to establish a clean monitoring baseline

## Description

Clears all accumulated wait statistics from sys.dm_os_wait_stats by executing DBCC SQLPERF (N'sys.dm_os_wait_stats', CLEAR). This is essential for performance troubleshooting when you need to establish a new baseline for wait analysis. DBAs commonly clear wait stats after resolving performance issues, during maintenance windows, or when beginning focused monitoring periods to isolate specific workload patterns without historical noise.

## Syntax

```powershell
Clear-DbaWaitStatistics
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

```

## Examples

### Example 1: After confirmation, clears wait stats on servers sql2008 and sqlserver2012

```powershell
PS C:\> Clear-DbaWaitStatistics -SqlInstance sql2008, sqlserver2012
```

### Example 2: Clears wait stats on servers sql2008 and sqlserver2012, without prompting

```powershell
PS C:\> Clear-DbaWaitStatistics -SqlInstance sql2008, sqlserver2012 -Confirm:$false
```

### Required Parameters

##### -SqlInstance

The target SQL Server instance or instances.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | True |
| Pipeline | true (ByValue) |
| Default Value |  |

### Optional Parameters

##### -SqlCredential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).  
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.  
For MFA support, please use Connect-DbaInstance.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.  
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.  
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | False |

##### -WhatIf

If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.

| Property | Value |
| --- | --- |
| Alias | wi |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -Confirm

If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.

| Property | Value |
| --- | --- |
| Alias | cf |
| Required | False |
| Pipeline | false |
| Default Value |  |

## Outputs

**PSCustomObject**

Returns one object per SQL Server instance, confirming the operation status.

**Properties:**

- ComputerName: The name of the computer hosting the SQL Server instance
- InstanceName: The SQL Server instance name
- SqlInstance: The full SQL Server instance name (ComputerName\InstanceName)
- Status: Either "Success" if the wait statistics were cleared, or the exception message if the operation failed

---

Part of [dbatools](https://dbatools.io/), a free and open source PowerShell module for SQL Server administration. Full command index: https://dbatools.io/commands/
