SQL Statement Formatting Tool

Source: Internet
Author: User
The SQL statements tracked by the event probe are very difficult to understand. After a long time, I found several suitable tools to format the SQL statements.

1. SQL pretty printer:
It feels good to use it, but the registration key cannot be found. It can only be converted to 50 rows. Unfortunately, I don't know if a brother with a key can send me one.

2. Toad for SQL Server 3.1 Freeware
This newly created SQL statement is quite good and also has a query analyzer, but it does not seem to be able to format the existing SQL statement.

3. vim + SQL formatting script
Totally free combination
Check out an official column.

Examples:

Original:
SELECT m. MSG_ID, m. PRIORITY_ID, CUST. CUST_NBR, CUST. CUST_NM,
CUST. CUST_LEGAL_NM, CUST. STORE_ADDR_1, CUST. STORE_ADDR_2,
CUST. CROSS_STREET, XMLELEMENT ('alerts', XMLELEMENT ('alert _ alert_id ',
Alert_id), XMLELEMENT ('alert _ agent_id ', agent_id), XMLELEMENT (
'Alert _ alert_type_id ', alert_type_desc), XMLELEMENT (
'Alert _ alert_date ', alert_date), XMLELEMENT (
'Alert _ url_reference ', url_reference), XMLELEMENT (
'Alert _ read_status ', read_status) CUST. STORE_CITY,
CUST. STORE_ST, CUST. POST_CODE, CUST. STORE_MGR_NM, from messages m JOIN
PRIORITY_CD p where m. to_person_id =? AND p. NAME = 'pri _ EMERGENCY 'AND
P. JOB = 'plumber 'AND m. status_id <(SELECT s. STATUS_ID FROM
MSG_STATUS_CD s WHERE s. NAME = 'msg _ read') order by m. msg_id desc


Formatted:
SELECT m. MSG_ID, m. PRIORITY_ID, CUST. CUST_NBR, CUST. CUST_NM,
CUST. CUST_LEGAL_NM, CUST. STORE_ADDR_1, CUST. STORE_ADDR_2,
CUST. CROSS_STREET,
XMLELEMENT (
'Alerts', XMLELEMENT ('alert _ alert_id ', alert_id ),
XMLELEMENT ('alert _ agent_id ', agent_id ),
XMLELEMENT ('alert _ alert_type_id ', alert_type_desc ),
XMLELEMENT ('alert _ alert_date ', alert_date ),
XMLELEMENT (
'Alert _ url_reference ', url_reference
), XMLELEMENT ('alert _ read_status ', read_status)
) CUST. STORE_CITY, CUST. STORE_ST, CUST. POST_CODE,
CUST. STORE_MGR_NM
From messages m
JOIN PRIORITY_CD P
WHERE m. to_person_id =?
AND p. NAME = 'pri _ EMERGENCY'
AND p. JOB = 'plumber'
AND m. status_id <(
SELECT s. STATUS_ID
FROM MSG_STATUS_CD s
WHERE s. NAME = 'msg _ read'
)
Order by m. msg_id desc

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.