General SQL Parser and SQL Pretty Printer Formatter options

Index

After formatting sql, beautified sql was in plain text. There are 2 ways you can generate beautified sql in colored text with syntax highlighting, RTF and HTML output.

  • RTF output, with this output, colored sql can be viewed in any editor that supported rtf format, such as writer and ms word. and you can use microsoft Rich Editor component in your app to add syntax highlighting function with RTF output.
  • HTML output, with this output, colored sql can be published in website, blog, wiki and so on.
The default font of output is Courier New, and it works fine. Please don't change this font although you can set new font by using gFmtOpt.HighlightingFontname. The default font size of output is 10, and it can be changed by setting new value to gFmtOpt.HighlightingFontsize. HighlightingFontname and HighlightingFontsize apply to whole output, and you can also customize each token with different color and style by using
  • TLzHighlighterAttributes[TLzHighlightingElement].SetForegroundInRGB
  • TLzHighlighterAttributes[TLzHighlightingElement].StyleItalic
  • TLzHighlighterAttributes[TLzHighlightingElement].StyleBold
  • TLzHighlighterAttributes[TLzHighlightingElement].StyleStrikeout
  • TLzHighlighterAttributes[TLzHighlightingElement].StyleUnderline


Example format options:

NameValue
TLzHighlighterAttributes[sfkIdentifer].SetForegroundInRGB#000000(black)
TLzHighlighterAttributes[sfkIdentifer].StyleItalictrue

Formatted SQL:

SELECT p.name      AS product,
       p.listprice AS 'List Price',
       p.discount  AS 'discount' 
FROM   production.product p 
       JOIN production.productsubcategory s ON p.productsubcategoryid = s.productsubcategoryid 
WHERE  s.name LIKE @product 
       AND p.listprice < @maxprice;