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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.