I am trying to run a SQL script locally using sqlcmd
, but I keep getting the following response:
HResult 0xFFFFFFFF, Level 16, State 1
SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF].Sqlcmd : error : Microsoft SQL Server Native Client 10.0 : 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..
Sqlcmd : error : Microsoft SQL Server Native Client 10.0 : Login timeout expired
I am running the following command:
sqlcmd -S Server\DbName -E -i C:\data.sql
I have also tried with 127.0.0.1\DbName
and localhost\DbName
. Same result. I have also looked in the configuration manager and made sure Named Pipes and TCP are enabled for SQL Native Client 10.0.
How do I get this script to run?
You should try this:
sqlcmd -S Server -d DbName -E -i C:\data.sql
You need to specify the server after the -S
and the database separately, with a -d
parameter.
If you're using a non-standard/non-default server instance, then you need to specify that with the -S
parameter, e.g. if you're using the default SQL Server Express instance, use this:
sqlcmd -S Server\SQLEXPRESS -d DbName -E -i C:\data.sql
Here, Server\SQLEXPRESS
is the server instance name - not the server+database name!