Useful SQL Colouring Tool

Crayons

I guess it depends on your background but if you’re anything like me you’ll prefer to have your SQL coloured and formatted, I began writing SQL in Microsoft SQL Server’s Query Analyser which colours comments green, keywords blue, aggregate functions pink and string values in red – and it’s something I (almost) can’t live without.

It’s become a fairly common scheme for viewing SQL and years of being used to colours mean that reading too much monochrome SQL drives me crazy so when I started this blog I was a concerned about how off-putting it would be if I posted reams of plain old SQL, luckily a bit of Googling led to me finding Instant SQL Formatter.

Instant SQL Formatter allows you to format and colour a SQL statement and then provides you with the HTML that you can paste right into your blog, there are also lots of options to tweak the formatting based on how you’d like to see the SQL laid out.  Here’s some example SQL I wrote using the tool…


– TESTING COLOURED SQL QUERY
SELECT Species,
COUNT(DISTINCT AnimalID) AS NumberOfAnimals
FROM tblAnimal
WHERE Species IN (‘Bonobo’,‘Vervet’,‘Chimpanzee’)
AND IsHealthy = 1
GROUP BY Species
HAVING COUNT (DISTINCT AnimalID) > 1