sql-serversecurityauthenticationosql

SQL Server Login Using OSQL.exe


From Visual Studio 2010 I can connect to my SQL Server Express 2005 instance - by specifying windows authentication. However, when I use a command like it doesn't work:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>osql -S SQLEXPRESS -U Quixote
nt -P Password.0
[SQL Native Client]Named Pipes Provider: Could not open a connection to SQL
Server [53].
[SQL Native Client]Login timeout expired
[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.

Incidentally, the above does not actually list my windows name and password - I just substituted examples. What am I doing wrong?


Solution

  • You cannot use -U and -P if you want to connect with windows authentication. That is for SQL authentication. Use -E instead:

    osql -S SQLEXPRESS -E