I'm getting the syntax error of Incorrect syntax near 'GO'
. I tried a few methods and one of them worked. Anyone can explain it to me?
Source for invoke-sqlcmd2: https://github.com/RamblingCookieMonster/PowerShell/blob/master/Invoke-Sqlcmd2.ps1
Worked:
Invoke-Sqlcmd2 -Query "SELECT 1 FROM TableA GO"
Didn't work:
Invoke-Sqlcmd2 -Query "Print 123 GO"