Partilhar via


Format SQL script

It has little to do with Sharepoint per se but I find it very useful to format the ugly scripts:

And yes, it can be improved and refined.

$s=Read-host "All in one line script"

$s=$s.Replace(",",",`n").Replace("SELECT","`nSELECT").Replace("FROM","`nFrom").Replace("INNER","`n`tINNER").Replace("CASE","`n`t`tCASE").Replace("INSERT","`nINSERT").Replace("`n`n","`n")

$s|out-file C:\temp\Formatted.sql