A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified)

-> Client advised that they are trying to connect to a SQL Server named instance and getting below error,

Blog90_1

TITLE: Connect to Server
——————————
Cannot connect to JBAG1\IN01.
——————————
ADDITIONAL INFORMATION:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=-1&LinkId=20476
——————————
BUTTONS:
OK
——————————

-> Client advised that they were able to connect to a default instance that is installed on the same server.

-> Client also advised that there were no recent network changes in the database server.

-> I wanted to make sure if SQL Services was online. In my case it was online.

-> Then I checked if Remote connection was enabled from SQL Server Instance Properties -> Connection -> “Allow remote connections to this server”. It was checked.

-> Verified if “SQL Server Browser Services” was started. It was started.

-> Checked what protocols were enabled. In my case TCP\IP and shared memory was enabled. Checked further if TCP\IP is configured to use static or dynamic port.

TCP\IP was configured with a static port of 51233.

-> Verified if there was an “inbound Rule” to allow TCP port 51233 in the firewall. It was already created.

-> Checked if there were any bad alias created in SQL Server Configuration manager or cliconfg.exe. There were none.

-> I tried executing Telnet and understood that port 51233 is open. I also got the port scan output from the client and it showed that the port was open.

-> I tried to connect to the SQL Server named instance using Servername,port instead of Servername\Instancename. The connection was successful.

-> The connection doesn’t work only if I use Servername\Instancename. I checked further and then realized that someone have changed Hide Instance to Yes in configuration manager.

Blog90_2

Blog90_3

Hide Instance : SQL Server uses the SQL Server Browser service to enumerate instances of the Database Engine installed on the computer. This enables client applications to browse for a server, and helps clients distinguish between multiple instances of the Database Engine on the same computer. Setting Hide Instance to YES will prevent the SQL Server Browser service from exposing an instance of the Database Engine to client computers that try to locate the instance by using the Browse button. Setting Hide Instance to Yes is a security best practice, but can cause issue as detailed in this post.

-> I advised this to the client and changed “Hide Instance” Setting to No and the connection went through fine. Please note that this change doesn’t require a SQL Server restart.

-> Client advised that one of their DBA’s changed this recently after a security assessment of their SQL Server instance using SQL Server vulnerability assessment report from SQL Server Management studio. Advised them that they can perform below to connect to SQL Server named instance using “Hide Instance” set to Yes,

1) Change the application connection string from Servername\Hostname to Servername,Port.

2) Create a ALIAS in SQL Server configuration manager or cliconfg.exe.

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights.

Removing IAM page %S_PGID failed because someone else is using the object that this IAM page belongs to

-> I was executing DBCC SHRINKFILE as an one time operation on a huge data file to move its data into 4 additional data files using below command,

USE [Financedb]
GO

DBCC SHRINKFILE (N'Finance_Data' , EMPTYFILE)
GO

-> I received below error when executing above command,

Msg 1119, Level 16, State 1, Line 20
Removing IAM page (3:5940460) failed because someone else is using the object that this IAM page belongs to.

-> I executed DBCC CHECKDB and there were no errors,

DBCC results for ‘Financedb‘.
.
.
CHECKDB found 0 allocation errors and 0 consistency errors in database Financedb.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.

-> This is not a corruption issue. I restarted SQL Services and executed below command and it ran through.

USE [Financedb]
GO
DBCC SHRINKFILE (N'Finance_Data' , EMPTYFILE)
GO

Msg 2555, Level 16, State 1, Line 20
Cannot move all contents of file “Finance_Data” to other places to complete the emptyfile operation.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.

-> Above message is due to the fact that System objects cannot be moved.

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights.

MYSQL Linked server in SQL Server

-> Download the installation file of MySQL Connector/ODBC 5.3 from https://dev.mysql.com/downloads/connector/odbc/5.3.html.

Blog77_1Blog77_2Blog77_3Blog77_4Blog77_5

-> Once installed, create a System DSN in ODBC Data Sources (64-bit) as below,

Blog77_6Blog77_7Blog77_8Blog77_9

-> Select the required database and test the connection to ensure it works.

-> Once the datasource is created. Create a linked server as below,

Blog77_10Blog77_11

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights.