Showing posts with label microsoft sql server error 2. Show all posts
Showing posts with label microsoft sql server error 2. Show all posts

Wednesday, February 17, 2021

SQL SERVER - How to capitalize the first letter of a record in SQL

 Cast your ntext to nvarchar(max) and do the upper and left operations. Sample below.

SELECT UPPER(LEFT(cast(Comments as nvarchar(max)),1)) +
LOWER(SUBSTRING(cast(Comments as nvarchar(max)),2,
LEN(cast(Comments as nvarchar(max)))))  
FROM dbo.Template_Survey;

Following should work for update.

Update dbo.Template_Survey SET Comments = 
UPPER(LEFT(cast(Comments as nvarchar(max)),1)) +
LOWER(SUBSTRING(cast(Comments as nvarchar(max)),2,
LEN(cast(Comments as nvarchar(max)))));  

Thursday, March 14, 2019

A network-related or instance-specific error occurred while establishing a connection to SQL Server - microsoft sql server error 2


SSMS Error: "A network-related or instance-specific error occurred while establishing a connection to SQL Server"

When you are trying to connect to a SQL Server using Microsoft SQL Server Management Studio, you may see the following message:

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 the SQL Server is configured to allow remote connections. (provided: Named Pipes Provider, error: 40- Could not open a connection to the SQL Server) (Microsoft SQL Server, Error: 2).

While the message tells you to check some of the items that can cause this issue, it fails to mention that if your SQL Server Service is not started, then you cannot connect. One of the first things that you should check is that the SQL Server (MSSQLSERVER) is started. You can go to the Services Console (services.msc) and look for SQL Server (MSSQLSERVER) to see that it is started. If not, then start the service.

You could also do this through an elevated command prompt by typing net start mssqlserver.