How to Check SQL Server Connectivity from SharePoint?
How do I quickly check SQL Server connectivity from the SharePoint server? Well, you can use Telnet.
telnet {SQL-Server-Name or IP} 1433
If your SQL Server listens on a different port, change the default port 1433 accordingly.
Using PowerShell to test SQL server connectivity:
You can also use PowerShell to check if SharePoint is able to connect with SQL Server:
(New-Object System.Net.Sockets.TCPClient("SQL-Server-Name",1433)).Connected
This tells you whether the particular PORT is open on the given server.
Check SQL Server Connectivity by establishing a connection:
Run this PowerShell script to test whether you are able to connect with SQL Server.
Function Check-SQLServerConnection([string]$serverInstance)
{
$connectionString = "Data Source={0};Integrated Security=true;Application Name=CheckSQLServer" -f $serverInstance;
$sqlConn = new-object("Data.SqlClient.SQLConnection") $connectionString;
Write-Host $connectionString
try {
$sqlConn.Open();
$sqlConn.Close();
Write-Host "Connected OK"-foregroundcolor white -backgroundcolor green
}
catch {
Write-Host $_ -foregroundcolor white -backgroundcolor red
}
finally {
$sqlConn.Dispose();
}
}
#Call the function with your SQL Server Machine Name
Check-SQLServerConnection "SP13-SQL01"