Created
April 26, 2023 00:31
-
-
Save kenzauros/746587214fbd97431860e9a6bf558930 to your computer and use it in GitHub Desktop.
SQL 結合用 PowerShell スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param( | |
[parameter(mandatory)][String]$outputFile | |
) | |
$divider="-- $("=" * 100)" | |
$files = Get-ChildItem .\*.* -Include *.sql -Exclude $outputFile | |
if (Test-Path $outputFile) { Clear-Content $outputFile } | |
function output { | |
process { | |
Out-File -Encoding UTF8 -FilePath $outputFile -Append -InputObject $PSItem | |
} | |
} | |
foreach ($file in $files) { | |
Write-Output $divider | output | |
Write-Output "-- $($file.Name)" | output | |
Write-Output $divider | output | |
Get-Content $file.FullName -Encoding UTF8 ` | |
| Select-String -Pattern "^(BEGIN TRAN|ROLLBACK)" -NotMatch ` | |
| Select-Object -ExpandProperty line | output | |
Write-Output "GO`r`n" | output | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment