Replies: 1 comment 2 replies
-
Yes indeed, you can use PowerShell for this, here's some pseudocode $files = Get-ChildItem C:\scripts
foreach ($file in $files) {
try {
Invoke-DbaQuery -SqlInstance sql01 -File $file.FullName -EnableException
$file | Rename-Item -NewName { $PSItem.Name -Replace '.sql','.Success' }
} catch {
$file | Rename-Item -NewName { $PSItem.Name -Replace '.sql','.Failed' }
}
}
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi I was wondering if it is possible to use this tool to run a folder of . SQL files and rename the file to . Success if it executed successfully, otherwise rename to . Failed and stop running on fail...
Beta Was this translation helpful? Give feedback.
All reactions