3

I downloaded the 53.5 MB setup of SQL Server 2005 Express from this URL:

Microsoft SQL Server 2005 Express Edition

Then I ran sqlcmd by going into command promp , but it shows error

HResult 0x2, Level 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server 2.
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.

Then I downloaded and installed Sql Command Line Utility from this URL:

Feature Pack for Microsoft SQL Server 2005 - November 2005

Then also it shows the same error.

Then I installed Sql Native Client, then also it didn't work. But when I installed Management Studio, then from Management Studio the connection is established, but not from sqlcmd from Command Prompt.

Please help.

AminM
  • 1,658
  • 4
  • 32
  • 48
sqlchild
  • 8,754
  • 28
  • 105
  • 167
  • 2
    Can you tell us: (1) what server name you use in SQL Server Mgmt Studio?? Show us: (2) what your SQLCMD command line looks like?? – marc_s Apr 27 '11 at 11:51
  • @marc_s : Sir , the server name is : W\SQLEXPRESS , how do i tell the SQLCMD command line? its just: C:\sqlcmd , also can i change the instance name? my computer name is W – sqlchild Apr 28 '11 at 08:02
  • 1
    @sqlchild: so how did you **run sqlcmd** ??? What parameters did you pass?? – marc_s Apr 28 '11 at 11:33
  • i just typed C:\sqlcmd , nothing else, also when i type C:\sqlcmd -L, then it shows only -- " SERVERS: " , and nothing else, no server name nothing – sqlchild Apr 28 '11 at 11:50
  • 1
    What if you do something like: `sqlcmd -S W\SQLEXPRESS -E -d master -q "select * from sys.tables"` – marc_s Apr 28 '11 at 12:55
  • SIR, it worked, thanks a lot, but whats the problem if i give only sqlcmd? also, are SqlCommandLine utility and Sql Native client installations are necessary for runninn sqlcmd? Din't these both came bound into the Sql Server 2005 Express setup? – sqlchild Apr 28 '11 at 14:05

2 Answers2

4

"Just typing sqlcmd on its own won't work - how should the utility know what server to connect, what database to use, and what command to run??" Funny thing. As I read the Microsoft documentation, just typing sqlcmd while sitting on the server should open a connection to this server. At least it can, depending on settings for security. Typing sqlcmd without any options for login/security may very well fail, but the utility will defintely try.

And SQLCMD without quit is just that, right?

olga
  • 41
  • 1
3

What if you do something like:

sqlcmd -S W\SQLEXPRESS -E -d master -q "select * from sys.tables"

Just typing sqlcmd on its own won't work - how should the utility know what server to connect, what database to use, and what command to run??

You need to tell sqlcmd what you want to do! Get a list of its command options using sqlcmd -?, study them, and use them! Or read the MSDN docs on Using the sqlcmd utility with SQL Server Express - btw: searching MSDN for answers and documentation would be a good idea for all your SQL Server problems......

The SQL Native Client is definitely needed, yes - not sure what you mean by the second package there.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • thanks a lot sir, but previously when i had installed sql express, then it connected via sqlcmd, by only typing in C:\sqlcmd, and it connected, there was no problem. also, how do i change the instance name, which is currently SQLEXPRESS, could it be changed? – sqlchild Apr 29 '11 at 06:19
  • 1
    @sqlchild: you would need to uninstall and re-install SQL Server to change the instance name – marc_s Apr 29 '11 at 06:25