SQL 2005 character-based SQLCMD utility does not work

I open the Command prompt (using vista premium home)
I get
C:\Users\Avner>
I type
SQLCMD
and i get
HResult 0X2, Level 16,  State 1
Named Pipe Provider: Could not open a connection to SQL Server [2].
Sqlcmd: Error: Microsoft SQL native Client: An Error has occurred while astablishing a connection to the server

(now it suggests that the default settings do mot allow remote connection.. but i believe i enabled it)
HResult 0X2, Level 16,  State 1
Named Pipe Provider: Could not open a connection to SQL Server [2].
Sqlcmd: Error: Microsoft SQL native Client: An Error has occurred while astablishing a connection to the server

Open in new window

Avner_LAsked:
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.

lexiflexCommented:
Have tried using the -S and -E or -U and -P parameters?

SQLCMD -S <instancename> -E
or
SQLCMD -S <instancename> -U <login> -P <password>

<instancename> could be <servername>\<instancename> for a named instance or just <servename> for a primary instance.
0
Avner_LAuthor Commented:
What should I write in  instancename?
if iwrite excatly as you did, I get
"The system cannot find the file specified"
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
if it is a named instance, you have to put
servername\instancename

or, if the sql server is installed locally, simply
.\instancename

0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Avner_LAuthor Commented:
I am sorry i am not sure if the sql is installed locally

and...  my computer is called  AVNER-PC
what exactlly do i write?

in my manual it is suggested that if i just type SQLCMD a connection must be established
0
lexiflexCommented:
Are you able to connect to the SQL Server with SQL Server Management Studio or any other application? If so what is the name featured as servername in the login-box or Object Browser?
0
Avner_LAuthor Commented:
Yes i can
With managemant studio
the server name is

AVNER-PC\SQLEXPRESS
0
lexiflexCommented:
Alright, try this with sqlcmd:

SQLCMD -S "AVNER-PC\SQLEXPRESS" -E

The -S switch is the SQL Server you're connecting to and the -E means you're connecting with integrated security.
I added the quotes because I'n not sure SQLCMD can handle the "-" sign in the servername otherwise.
0
Avner_LAuthor Commented:
These are the results:
i type

SQLCMD -S "AVNER-PC\SQLEXPRESS" -E
 and i get
Sqlcmd: '   '  : Unknown option. Enter '?' for help

and when i try the same with '  instead of " 
it again defines an error
0
lexiflexCommented:
That's weird, when run this exact command I get a message about not being able to connect to the SQL Server instance.

Could you run the SQLCMD -? command to find out which version it is running. See example below.
C:\>sqlcmd -?
Microsoft (R) SQL Server Command Line Tool
Version 9.00.3042.00 NT INTEL X86
Copyright (c) Microsoft Corporation.  All rights reserved.

Open in new window

0
Avner_LAuthor Commented:
That's exactly what i get
(version 9... etc)
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what about this:
SQLCMD -S AVNER-PC\SQLEXPRESS -E
0
Avner_LAuthor Commented:
ok
so i type
SQLCMD -S AVNER-PC\SQLEXPRESS -E
i get
1>

what now?
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
now you are connected successfully, and you can run the sql commands:
technet.microsoft.com/en-us/library/ms162773.aspx

0

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
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 2005

From novice to tech pro — start learning today.