microsoft / SQLServerPSModule

This repo is the home of SQL Server PowerShell Module development.
MIT License
51 stars 1 forks source link

Invoke-Sqlcmd does not parse correctly some string literal containing strings that resemble variables. #22

Closed Matteo-T closed 1 year ago

Matteo-T commented 1 year ago

Run the following cmdlet:

invoke-sqlcmd -ServerInstance SQLTOOLS2022-3  -DisableVariables -Query "SELECT N'  ''`$(ESCAPE_SQUOTE(SRVR))'' '"

Result:

Invoke-Sqlcmd:
Line |
   1 |  invoke-sqlcmd -ServerInstance SQLTOOLS2022-3  -DisableVariables -Quer …
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Incorrect syntax was encountered while parsing '$(ESCAPE_SQUOTE('.

Expected:

Column1
-------
  '$(ESCAPE_SQUOTE(SRVR))'
Matteo-T commented 1 year ago

I need to pick up an updated ManagedParser with the fix for https://github.com/microsoft/sqltoolsservice/issues/1936 and wire up the new property.

Matteo-T commented 1 year ago

This is fixed in v22.0.52.2+ (when available)