SQL Server Is there a Tidy for SQL?

lokaqttq  于 2023-02-21  发布在  其他
关注(0)|答案(7)|浏览(123)

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 Tidy , but for SQL which is free/open source?

2ic8powd

2ic8powd1#

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, command line 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 an SQL Server 2008 R2 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)
jutyujz0

jutyujz03#

I use Instant SQL Formatter occasionally. It does the job for me.

iyzzxitl

iyzzxitl4#

The format() function in python-sqlparse works nicely for me.

sauutmhj

sauutmhj5#

You could try the free Simple Talk Prettifier.

It's basic, but it might satisfy your requirements.

c86crjj0

c86crjj06#

An SSMS 2005/2008 addin: http://code.google.com/p/sqlformat/

It lacks some features, but it is very a good start.

yrefmtwq

yrefmtwq7#

SQL::Beautify may or may not help (a Perl module). I haven't tried it.

相关问题