• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1510
  • Last Modified:

sqlcmd Connection error

I have a .sql file as below:
USE dan_test
SELECT     uname, upwd
FROM         dbo.dan
I am trying to run this from the Vista command line with the following command:
sqlcmd -S DANHP\SQLEXPRESS -i C:\ftp\test.sql -o C:\ftp\output.rpt

the output file returns the following error:

HResult 0xFFFFFFFF, Level 16, State 1
SQL Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF].
Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections..
Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.

I have checked the server settings and Allow remote connections to this server is enabled and I am using mixed mode authentication and am going to use windows authentication.
When I get this working I will create a bat file to run in windows scheduler.

Thanks is adance for any help.
  • 3
  • 3
1 Solution
Some things to check:
1.  The syntax of the server\instance name of DANHP\SQLEXPRESS is correct
2.  The server instance is running (to be sure it's running, execute the following from a command line:  net start MSSQL$SQLEXPRESS)
3.  Remote connections to the server\instance are allowed for both TCP/IP AND Named Pipes
panhead802Author Commented:
I ran net start MSSQL$SQLEXPRESS and got the error access is denied.

I have the SSMSE running DANHP\SQLEXPRESS is the server\instance name

the only way I know to check the remote connections is through the SSMSE and in the server properties under connections the check box for allow remote connections is checked. I am not sure if it is for Named Pipes.
Run a trace - find out what the login is trying to authenticate as:
1.  Close all DB connections
2.  Open SQL Mgmt Studio - do not connect to a server.
3.  In Sql Mgmt Studio, open Tools -> SQL Profiler
4.  Click New Trace
5.  Run your sqlcmd from the command line
6.  Post your results here

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

panhead802Author Commented:
I am using SQL 2005 Express, and SQL Server MAnagement Studio Express. SQL Profiler is not there.
Try forcing a valid username/password that you know works by using the following syntax in your cmd line:
sqlcmd -s DANHP\SQLExpress -u username -p password -i C:\ftp\test.sql -o C:\ftp\output.rpt

I believe if you leave out the -p parameter that you get prompted for a password, which is not a bad idea because the password will be sent in plain text and will appear in the command window for the world to see so be careful ;)
Let me know how it goes.
panhead802Author Commented:
Issue was with the SQL Server permissions on my Vista machine. I tested as you suggested on my 2K3 Server and all is well with the world thanks for the assistance.


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now