Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sql server: error 997 when specifying password in the command line

Tags:

sql-server

In SQL server 2014, I try to invoke a sql script using command line:

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

and I get an error message: Login failed for user 'sa' OS Error 997 Overlapped I/O operation is in progress.

However, when I run the command in interactive mode:

~ osql -U sa -i script.sql

it asks for password and the command succeeds. Can someone please help me how to run sql scripts purely from command line without user intervention?

thanks.

like image 678
Sankaran Avatar asked Sep 25 '14 07:09

Sankaran


People also ask

What is error code 997?

Error 997. Overlapped I/O operation is in progress: KB2918614 breaks Windows Installer Service Hope this would help. If issue still persists post back with the information required, current status of your computer and result of the proposed suggestion, we will be happy to assist you. Ramesh Kumar.

Is the password for reporting services service in SQL Server 2017?

No longer applicable starting with SQL Server 2017. Specifies the password for the startup account for Reporting Services service. This parameter can be omitted when using a managed service account, virtual account, or built-in account. No longer applicable starting with SQL Server 2017.

How do I reset the password for MY SQL Server startup account?

If the SQL Server Startup account is a Local User Account on the computer, open Computer Management (compmgmt.msc), and reset the password of the local user. If the SQL Server Startup account is a Windows Domain Account, open Active Directory Users and Computers, and then change the credentials.

Why do I get a login name and password error message?

The error message entry indicates that the current login name or password set is incorrect. To verify the same, you can use the Run-As Windows option to open a Windows Command Prompt window, and then provide the same credentials. If that works without any issues, carefully type the credentials in SQL Server Configuration Manager.


2 Answers

I just ran into a 997 error when using osql as well. It would appear that osql is not reporting errors correctly, giving error 997 instead of a more helpful error. Presumably this is due to it being deprecated.

In my case, the actual cause was the Server Authentication mode being set to "Windows Authentication mode" rather than "SQL Server and Windows Authentication mode". This can be changed by connecting using SQL Server Management Studio and going into the top level properties for the connection, then selecting the Security page.

Additionally, I had to enable the sa login, via Security -> Logins -> sa -> right click -> Properties on the Object Explorer, then setting the login to Enabled using the Status page.

like image 138
Cam Sinclair Avatar answered Sep 29 '22 15:09

Cam Sinclair


This happened to me, and it came down to the wrong password.

like image 29
MiloTheGreat Avatar answered Sep 29 '22 15:09

MiloTheGreat