Just posting some advice in case someone else stumbles onto an issue like this.
The SQLSTATE = 42000 a catch all basin for everything under the sun from Microsoft can lead you in circles. Here's another gotcha.
When using a PB 2019 R3 application we noticed an error when running pb script to generate pdfs from datastore's at retrieve time.
The datastore LDS_bject.retrieve() for example would throw:
Select Error: SQLSTATE = 42000 Microsoft SQL Server Native Client 11.0 Incorrect syntax near '*'.
Was solved by:
Changing your DbParm connection string parameter from : OJSyntax='PB' to OJSyntax='ANSI'
(*Or if you dont have the OJSyntax='' setting, then add it to be used during your SQL Server DB Connection)
Used when using Right outer join queries in the PB Datawindows appears to require this at least in some situations anyhow.
The symptom will be that the datawindow will retrieve without issues when connected and previewed / retrieved inside the PowerBuilder IDE,
however when running compiled application or during runtime retrieving the datawindow using a datastore or inside a datawindow on a window it will throw the error message indicated above.
Anyhow, happy trails, Hope this helps someone else.