Online sql formatter

Earlier this year we wrote about an online syntax highlighter that could take a block of code and format it in a way that makes it easier for people to read. While it worked with a lot of various programming languages it doesn’t have as many customization options as I would like it to have when sharing SQL database queries with other people. After some searching around I found theInstant SQL Formatter which supports MSSQL, MySQL, Oracle, and several other SQL query formats.

With this tool you’re able to take a very poorly formatted query and not only have the syntax highlighted but also have the format adjusted so that it is optimized for easy reading. You can also have it take a query and build code for a multitude of different programming languages. So if someone sends you a SQL query that you need to use in your PHP-based website you can drop it into this service, select PHP as the output, and it will spit out the PHP code needed to build the query. If you just want to share the query on a website you can grab the HTML output which retains all of the formatting you see in the example output. Pretty slick.

Here is an example of some poorly formatted SQL code that I used in the screenshot above and had converted to HTML:

SELECT TOP 100 sl.specobjid,
— get the spectroscopic object ID, the line ID, and the max width (in velocity)
FROM   specline sl,
(SELECT specobjid,
Max(2.99e5 * 2.354 * sigma / wave) AS maxVel
FROM   specline
— only include measured lines
category = 2
— only include the most prominent lines
lineid IN ( 1215, 1400, 1549, 1909,
2799, 4863, 6565 )
— make sure that this is a reaonably well measured line
— (these are fairly weak constraints)
nsigma > 3
AND chisq / nu < 20
AND ew > 0
AND Abs(ew – height * sigma * 1.065 * 2.354 / continuum) / ew <
0.25 )
GROUP  BY specobjid,
lineid) AS sMax

Instant SQL Formatter Homepage

Leave a Reply

Your email address will not be published. Required fields are marked *

6 + 18 =