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.
source share