microsoft / SQLServerPSModule

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

Invoke-Sqlcmd: -Variable parameter should accept a dictionary/hashtable #24

Closed Matteo-T closed 1 year ago

Matteo-T commented 1 year ago

The current way to pass -Variable (for the variable substitution) is not very user-friendly.

Invoke-Sqlcmd -Query "SELECT '`$(V1)' AS C1, '`$(V2)' AS C2" -TrustServerCertificate -Variable @("V1=1", "V2=2")

In addition to that, I would like to be able to say:

Invoke-Sqlcmd -Query "SELECT '`$(V1)' AS C1, '`$(V2)' AS C2" -TrustServerCertificate -Variable @{ V1=1;  V2=2 }

which feels a lot more natural and does not present all the possible issues related to having to parser strings to figure out values.

Matteo-T commented 1 year ago

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