SQL Formatter SQL Formatter

Use this add-in to apply a consistent style to long SQL strings, ready for insertion into VB.

Formatting SQL

Formatting SQL

Paste your SQL string, from example, Query Analyser, into the top TextBox, then click 'Format SQL' and the formatted SQL will appear in the lower TextBox, formatted to your options. The formatted SQL is automatically pasted into the clipboard.

If 'Declare Variable' is selected, a

Dim strSql As String 

statement is produced. The name of the variable used is by default taken from SQL Formatter options. If 'Line Continuation' is selected then the SQL goes out as one big line, with the maximum width taken from the 'Line Length' Option. If 'Line Continuation' is not selected then the SQL will be as below: -

strSql = "Select * from tblInvoices where InvoiceNo = "
strSql = strSql & "00017453"

'Double Quotes to Single Quotes' does what it says, converts the " character to the ' character. The final string is then passed through a VB function that ensures that the single quote character can't cause any problems when used with VB.