If anyone is working today I have a problem I'm working on.
I have a script which when run in SSMS, generates a SQL update script which is saved as an SQL file and run later. I am trying to automate this processes and generate a SQL file.
Based on what I've found in google searches I'm trying to do this in with Powershell:
invoke-SqlCmd -InputFile "C:\DBAScripts\Script.sql" -ServerInstance XXXX -Database XXXX | Out-File -filePath "F:\OutputPath\OutputScript.sql"
When I do this, I get a 0 kb empty file. The assumption in the posts I'm reading is that you want to save returned rows into a file, but when run in SSMS this input script puts the output in the Messages Tab.
The solution doesn't have to use Powershell. I just need a way to automate the running of a script and save the content of the Messages tab to a SQL file.
- This topic was modified 9 months, 3 weeks ago by dan-572483. Reason: make more clear
- This topic was modified 9 months, 3 weeks ago by dan-572483.