Skip to content

Instantly share code, notes, and snippets.

@matt40k
Created March 28, 2017 11:30
Show Gist options
  • Save matt40k/7be71ba7ff569650f233a156bb7cf940 to your computer and use it in GitHub Desktop.
Save matt40k/7be71ba7ff569650f233a156bb7cf940 to your computer and use it in GitHub Desktop.
Split up SQL file
$InputFile = 'C:\Input.txt'
$outDir = 'C:\Output'
$inputContent = Get-Content $InputFile
foreach ($line in $inputContent)
{
if ($line.Length -gt 0)
{
$firstChar = $line.Substring(0,1)
if ($firstChar -ieq 'C')
{
$objectName = $line.Substring(30)
$outFile = $outDir + '\' + $objectName.Substring(0, $objectName.IndexOf("]")) + '.sql'
$outContent = '--$Rev$' + "`n$line"
#Write-Host $outContent
Set-Content -Path $outFile -Value $outContent
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment