Project-Neith
Project-Neith copied to clipboard
Parameterized Queries?
Getting some errors like the following when imported data as variables include single quotes or similar characters:
Invoke-Sqlcmd : Incorrect syntax near 'Neil'.
Unclosed quotation mark after the character string ')
'.
Msg 102, Level 15, State 1, Procedure , Line 2.
At line:15 char:9
+ Invoke-Sqlcmd -Query $Query
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Invoke-Sqlcmd], SqlPowerShellSqlExecutionException
+ FullyQualifiedErrorId : SqlError,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand
I've heard Invoke-Sqlcmd2
might have a solution to this, this might be a better way forward
I believe I have an old example of using parameterized queries with this cmdlet. Please remind me this week unless you figure it out before.
Sweet, thanks!
On Sun, Feb 3, 2019 at 10:05 PM gallman [email protected] wrote:
I believe I have an old example of using parameterized queries with this cmdlet. Please remind me this week unless you figure it out before.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/theabraxas/UltimateDashboard/issues/14#issuecomment-460140313, or mute the thread https://github.com/notifications/unsubscribe-auth/AF3MvAvsIlEZrWwBoBWcsWMbWm5HoFWDks5vJ825gaJpZM4agjmo .
I haven’t checked the latest version of the SqlServer module but the dbaTools module supports parameterized queries via their Invoke-DbaSqlQuery function.