Sunday, February 12, 2012

Connect to SQL Server from Command Prompt?

I installed SQL Server CTP version and tried to connect from Command Prompt, but failed from either osql or sqlcmd:

osql [/sqlcmd] -H localhost -E

or,

osql [/sqlcmd] -H localhost -U sa -P SAPWD

The error message is:

Named Pipes Provider: Could not open a connection to SQL Server, ...

Please note named pipes are enabled from client protocol configuration.

without Management studio, how can I connect to the server?

Thanks.
PS: I had searched in the forum, but didn't find answer to above question.

-S is the parameter for the instancename e.g.

sqlcmd -S (local) -E

sqlcmd -S (local)\SQL01 -E

For a windows authenticated connection to the default instance on the local

machine you don't need any parameters for sqlcmd e.g

sqlcmd

--

HTH

Jasper Smith (SQL Server MVP)

http://www.sqldbatips.com

I support PASS - the definitive, global

community for SQL Server professionals -

http://www.sqlpass.org

wrote in message

news:f756a7ad-017a-42a5-aa70-0908ad626391@.discussions.microsoft.com...

>I installed SQL Server CTP version and tried to connect from Command

> Prompt, but failed from either osql or sqlcmd:

>

> osql [/sqlcmd] -H localhost -E

>

> or,

>

> osql [/sqlcmd] -H localhost -U sa -P SAPWD

>

> The error message is:

>

> Named Pipes Provider: Could not open a connection to SQL Server, ...

>

> Please note named pipes are enabled from client protocol configuration.

>

> without Management studio, how can I connect to the server?

>

> Thanks.

>

>

> PS: I had searched in the forum, but didn't find answer to above

> question.

>

>

>

>

>|||-S is the parameter for the instancename e.g.

sqlcmd -S (local) -E sqlcmd -S (local)\SQL01 -E

For a windows authenticated connection to the default instance on the local machine you don't need any parameters for sqlcmd e.g

sqlcmd

|||Thanks for the replies.

After a few attempts, I found the following command works:

osql (or sqlcmd) -S .\SQLEXPRESS -E

without instance name, it always timed out.

No comments:

Post a Comment