Sql server: error 997 when specifying a password on the command line

In SQL Server 2014, I am trying to invoke a sql script using the command line:

~ osql -U sa -P passwd -i script.sql

and I get the error message: Login failed for user 's' OS 997 error Overlapped I / O operation in progress.

However, when I run the command interactively:

~ osql -U sa -i script.sql

it asks for a password and the command completed successfully. Can someone please help me how to run SQL scripts exclusively from the command line without user intervention?

thanks.

+6
source share
3 answers

I just encountered error 997 when using osql. It seems that osql is reporting errors incorrectly, giving error 997 instead of a more useful error. Presumably, this is due to the fact that it is out of date.

In my case, the actual reason was the server authentication mode, which was set to "Windows Authentication Mode", not "SQL Server and Windows Authentication mode". This can be changed by connecting using SQL Server Management Studio and going to the top-level properties for the connection, then selecting the "Security" page.

In addition, I had to enable sa login using Security -> Logins -> sa -> right click -> Properties in the object browser, and then setting the login to Enabled using the status page.

+3
source

This happened to me, and it gave way to the wrong password.

+1
source

I had the same problem too. I tried sqlcmd instead of osql and it gave me a more understandable error, in my case the problem was that I used the wrong password for this particular database.

I can advise that if someone encounters a similar problem, use sqlcmd, which is the successor to the osql command. Also use -o to get a text file with the output of the problem.

0
source

Source: https://habr.com/ru/post/975816/


All Articles