Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tidy for SQL

I'm looking for a tool that that I can use to clean up (formatting, tabs etc...) my stored procedures and views. Is there anything like html's tidy, but for SQL which is free/open source?

like image 418
Rob Avatar asked Dec 09 '22 20:12

Rob


1 Answers

Three years later, I'd just like to round out this question with two options that seem to be missing, and I think are both more appropriate than most options listed so far:

  • Poor Man's T-SQL Formatter / poorsql.com (free, open-source, SSMS add-in, commandline formatter, full DDL/DML script formatting, and I'm the author/maintainer so I get to put it first :))
  • T-SQL Tidy (free, SSMS Add-In, full DDL/DML script formatting, apparently 2008R2 add-in can do offline formatting also now - but not open-source?)

I believe either of these makes more sense than any of the previous answers because the other options provided are:

  • Online-only (instant sql formatter)
  • Trialware / commercial software (sql pretty printer)
  • Don't format (SSMS tools pack, the accepted answer)
  • Don't handle full T-SQL properly (CPAN module, SQL-talk prettifier)
  • Incomplete, only handle some statements (SqlFormat project)
like image 199
Tao Avatar answered Dec 30 '22 21:12

Tao