Home > database >  SQL Server Express database instance connection error
SQL Server Express database instance connection error

Time:11-17

I am trying to run a SQL script locally using sqlcmd, but I keep getting the following error:

Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF].
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..

I am running the following command:

SQLCMD -S 127.0.0.1\SQLEXPRESS -Q "SELECT GETDATE();"

How do I get this script to run?

CodePudding user response:

Try using this:

SQLCMD -S .\SQLEXPRESS -Q "SELECT GETDATE();" 

Use a dot . instead of 127.0.0.1 as the "server name"; this stands for "local machine" and should give you access to your database.

Alternatives:

SQLCMD -S (local)\SQLEXPRESS -Q "SELECT GETDATE();" 

SQLCMD -S localhost\SQLEXPRESS -Q "SELECT GETDATE();" 
  • Related