dbatools is a free PowerShell module with over 180 SQL Server administration, best practice and migration commands included.


Test-SqlNetworkLatency

This command is intended to help measure SQL Server network latency by establishing a connection and making a simple query. This is a better alternative than ping because it actually creates the connection to the SQL Server, and times not only the entire routine, but also how long the actual queries take vs how long it takes to get the results.

Screenshots

latency

Examples

To time the execution of “SELECT TOP 100 * FROM sys.objects” 3 times on sqlserver2014a, using Windows Authentication to log into the server.

Test-SqlNetworkLatency -SqlServer sqlserver2014a

To time the execution results return of “select top 10 * from otherdb.dbo.table” 10 times on sqlserver2014a, sqlcluster, and sqlserver

Test-SqlNetworkLatency -SqlServer sqlserver2014a, sqlcluster, sqlserver -Query “select top 10 * from otherdb.dbo.table” -Count 10

Get-Help

From PowerShell, execute Get-Help Test-SqlNetworkLatency -Detailed for more information on this function.

Source Code

Want to see the source code? View Test-SqlNetworkLatency.ps1 on GitHub
 

Related commands