Forum Discussion
akau1902
Dec 08, 2020Copper Contributor
Powershell only executes first sql statement in the sql file
Hello Everyone, I am trying execute two simple SELECT statements placed in a sql file and then trying to execute the sql file via powershell and dumping the results in a text file using the below...
olafhelper
Dec 08, 2020Bronze Contributor
akau1902, the CmdLet Invoke-SqlCmd supports the full feature set of the SqlCmd utility, see https://docs.microsoft.com/en-us/powershell/module/sqlserver/invoke-sqlcmd?view=sqlserver-ps
So add a batch separator GO to your script =>
SELECT * FROM TABLE1
GO
SELECT * FROM TABLE2