Sunday, June 14, 2015

PowerShell: Cannot connect to SQL Server 2012, Why?

I Recently changed the windows login.

SQL Server 2012 using old login and did not launch---Good
Corrected the login info in (Control Panel)services--OK
Can launch SSMS and connect to named instance Hodentek8/RegencyPark--Good
--------------
I can start PowerShell in the context of the named instance in SSMS (this, I suppose assumes I am already connected to the instance)--Good
I can even create a new database using these:
--
PS SQLSERVER:\SQL\HODENTEK8\REGENCYPARK> $server= new-object Microsoft.Sqlserver.management.smo.server  'Hodentek8\RegencyPark'
PS SQLSERVER:\SQL\HODENTEK8\REGENCYPARK> $dbname="Jun14"
PS SQLSERVER:\SQL\HODENTEK8\REGENCYPARK> $db=new-object  Microsoft.Sqlserver.management.smo.Database ($server,$dbname)

PS SQLSERVER:\SQL\HODENTEK8\REGENCYPARK> $db.Create()
PS SQLSERVER:\SQL\HODENTEK8\REGENCYPARK>

I verify Jun14 database created in SSMS--Good
--
However when I try to run a query, I get the 'named pipes' related error--Not good
I check the client protocols in SQL Server Configuration manager; Client protocol 'Named Pipes' is enabled--Good
Stop and start the instance.--Good
The error persists--Not good
I am stuck!!

Here are the PowerShell statements to check status of the server:
--------------
PS SQLSERVER:\SQL\HODENTEK8\REGENCYPARK> Get-Service -name *sql* | Where-object{$_.Status -eq "Running"} | Format-Table -AutoSize

Status  Name                        DisplayName
------  ----                        -----------
Running MSSQL$REGENCYPARK           SQL Server (REGENCYPARK)
Running MSSQLFDLauncher$REGENCYPARK SQL Full-text Filter Daemon Launcher (REGENCYPARK)

Unfinished troubleshooting:

This error:
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Named Pipes Provider: Could not open a connection to SQL Server [2]. .
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login timeout expired.
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : A network-related or instance-specific error has occurred
while establishing a connection to SQL Server. Server is not found or not accessible.

I will post or edit this if I can resolve this.

No comments:

Post a Comment

What is SQLOISIM? What is it used for in SQL Server?

SQLIOSIM is a tool for simulating SQL Server IO. SQLIOSIM performs reliability and integrity tests on the disk systems that SQL Server uti...