views:

281

answers:

1

SQLCMD uses windows authentication by default. According to the MSDN documentation, you can change it by adding a -U parameter to the command and then the user name.

The problem is with the password. Is there any way to access the sql server if the password is blank?

sqlcmd -U admin
password:

Whenever I try this and just press enter (indicating that the password is an empty string), I get a message saying that the login failed.

Any suggestions? thanks

+1  A: 

This forum post http://social.msdn.microsoft.com/Forums/en-US/sqlsecurity/thread/15e4a7c0-6547-44e8-9e25-4f14c12570ca implies that sqlcmd does not support empty passwords. The workaround is to use osql.

However the documentation for sqlcmd here suggests you can use a blank password:

"If the -U option is used and the -P option is not used, and the SQLCMDPASSWORD environment variable has not been set, sqlcmd prompts the user for a password. If the -P option is used at the end of the command prompt without a password sqlcmd uses the default password (NULL)."

Hope one of those helps you!

James Holland
Thank you so much! The output has a slightly different format than the sqlcmd, but it works. Any idea what the differences between the 2 commands are?
chama
Well first there was isql, then osql with SQL Server 2000, and then sqlcmd came with SQL Server 2005 (when isql was removed). I'd guess that sqlcmd is meant to eventually replace osql but not sure.
James Holland