Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 26 additions & 23 deletions SQLConnectivityTest.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
$DatabaseServer = "xxxxx.database.windows.net"
$Database = "xxxxxx"
$Username = "xxxxxx"
$Password = "xxxxxx"
$DatabaseServer = "xxxx.database.windows.net"
$Database = "xxxx"
$Username = "xxxx"
$Password = "xxxx"
$Pooling = $true
$NumberExecutions =10
$File = "E:\TSQL.SQL"
$WorkingDirectory = "C:\TEMP\"
$File = $WorkingDirectory + "TSQL.txt"
$LogFile = $WorkingDirectory + "MyLog.txt"

cls

Expand Down Expand Up @@ -51,28 +53,29 @@ cls
$connection.Close()
$end = get-date
$data = $connection.RetrieveStatistics()
write-Output "-------------------------" | Out-File e:\my.log -Append -width 300
write-Output ("Query : " + $query[$iQuery]) | Out-File e:\my.log -Append -width 300
write-Output ("Iteration : " +$i) | Out-File e:\my.log -Append -Width 300
write-Output ("Time required (ms) : " +(New-TimeSpan -Start $start -End $end).TotalMilliseconds) | Out-File e:\my.log -Append -Width 300
write-Output ("NetworkServerTime (ms): " +$data.NetworkServerTime) | Out-File e:\my.log -Append -Width 300
write-Output ("Execution Time (ms) : " +$data.ExecutionTime) | Out-File e:\my.log -Append -Width 300
write-Output ("Connection Time : " +$data.ConnectionTime) | Out-File e:\my.log -Append -Width 300
write-Output ("ServerRoundTrips : " +$data.ServerRoundtrips) | Out-File e:\my.log -Append -Width 300
write-Output ("BuffersReceived : " +$data.BuffersReceived) | Out-File e:\my.log -Append -Width 300
write-Output ("SelectRows : " +$data.SelectRows) | Out-File e:\my.log -Append -Width 300
write-Output ("SelectCount : " +$data.SelectCount) | Out-File e:\my.log -Append -Width 300
write-Output ("BytesSent : " +$data.BytesSent) | Out-File e:\my.log -Append -Width 300
write-Output ("BytesReceived : " +$data.BytesReceived) | Out-File e:\my.log -Append -Width 300
write-Output "-------------------------" | Out-File e:\my.log -Append -Width 300
write-Output "-------------------------" | Out-File $LogFile -Append -width 300
write-Output ("Query : " + $query[$iQuery]) | Out-File $LogFile -Append -width 300
write-Output ("Iteration : " +$i) | Out-File $LogFile -Append -Width 300
write-Output ("Time required (ms) : " +(New-TimeSpan -Start $start -End $end).TotalMilliseconds) | Out-File $LogFile -Append -Width 300
write-Output ("NetworkServerTime (ms): " +$data.NetworkServerTime) | Out-File $LogFile -Append -Width 300
write-Output ("Execution Time (ms) : " +$data.ExecutionTime) | Out-File $LogFile -Append -Width 300
write-Output ("Connection Time : " +$data.ConnectionTime) | Out-File $LogFile -Append -Width 300
write-Output ("ServerRoundTrips : " +$data.ServerRoundtrips) | Out-File $LogFile -Append -Width 300
write-Output ("BuffersReceived : " +$data.BuffersReceived) | Out-File $LogFile -Append -Width 300
write-Output ("SelectRows : " +$data.SelectRows) | Out-File $LogFile -Append -Width 300
write-Output ("SelectCount : " +$data.SelectCount) | Out-File $LogFile -Append -Width 300
write-Output ("BytesSent : " +$data.BytesSent) | Out-File $LogFile -Append -Width 300
write-Output ("BytesReceived : " +$data.BytesReceived) | Out-File $LogFile -Append -Width 300
write-Output "-------------------------" | Out-File $LogFile -Append -Width 300
}
}
catch
{
Write-Output -ForegroundColor DarkYellow "You're WRONG" | Out-File e:\my.log -Append -Width 300
Write-Output -ForegroundColor Magenta $Error[0].Exception | Out-File e:\my.log -Append -Width 300
Write-Output -ForegroundColor DarkYellow "You're WRONG" | Out-File $LogFile -Append -Width 300
Write-Output -ForegroundColor Magenta $Error[0].Exception | Out-File $LogFile -Append -Width 300
}

}
write-Output ("Time spent (ms) Procces : " +$sw.elapsed) | Out-File e:\my.log -Append -Width 300
write-Output ("Review: https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/provider-statistics-for-sql-server") | Out-File e:\my.log -Append -Width 300
write-Output ("Time spent (ms) Procces : " +$sw.elapsed) | Out-File $LogFile -Append -Width 300
write-Output ("Review: https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/provider-statistics-for-sql-server") | Out-File $LogFile -Append -Width 300
"Please review " + $LogFile + " for test results"