Skip to content

Instantly share code, notes, and snippets.

@badmotorfinger
Created May 14, 2013 10:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save badmotorfinger/5575139 to your computer and use it in GitHub Desktop.
Save badmotorfinger/5575139 to your computer and use it in GitHub Desktop.
Formats all SQL scripts in a directory using a free webservice provided by tsqltidy.com and PowerShell.
$uri = 'http://www.tsqltidy.com/SQLTidy.asmx'
$proxy = New-WebServiceProxy -Uri $uri -class FormatSQL -Namespace FormatSQL
#Warning - Will format file contents and overwrite the original file. Use with caution.
gci *.sql | % { $content = $proxy.ParseSQL((get-content $_.FullName)); Set-Content $_.FullName $content; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment