Formating SQL syntax when pasting from MS Access



  • Newbie here - please bear with me. When I paste SQL into Notepad++, I would like to find a way to have it formatted into a syntax that’s easy to read for me as I’m not yet comfortable in SQL. Basically, not only to highlight certain syntax (like what the style configurator does) but also to split lines so they’re easier to read for me. Here’s an example:

    FROM THIS FORMAT
    SELECT SATURN_SFRSTCR.SFRSTCR_PIDM AS PIDM, SATURN_SFRSTCR.SFRSTCR_TERM_CODE AS TERM, …
    FROM (((((SATURN_SFRSTCR INNER JOIN SATURN_STVRSTS ON SATURN_SFRSTCR.SFRSTCR_RSTS_CODE = SATURN_STVRSTS.STVRSTS_CODE) INNER JOIN CAPMGR_SZVTRMC ON (CAPMGR_SZVTRMC.SZVTRMC_TERM_CODE = SATURN_SFRSTCR.SFRSTCR_TERM_CODE) AND (SATURN_SFRSTCR.SFRSTCR_PIDM = CAPMGR_SZVTRMC.SZVTRMC_PIDM)) INNER JOIN SATURN_SMRPRLE GROUP BY SATURN_SFRSTCR.SFRSTCR_PIDM, SATURN_SFRSTCR.SFRSTCR_TERM_CODE, SATURN_SPRIDEN.SPRIDEN_ID, SATURN_SPRIDEN.SPRIDEN_LAST_NAME, …
    HAVING (((SATURN_SFRSTCR.SFRSTCR_TERM_CODE)=“201710”) AND ((SATURN_SPRIDEN.SPRIDEN_CHANGE_IND) Is Null) AND ((GENERAL_GOREMAL.GOREMAL_EMAL_CODE)=“PERS”) AND …
    ORDER BY SATURN_SFRSTCR.SFRSTCR_PIDM;

    TO SOMETHING LIKE THIS FORMAT
    SELECT
    SATURN_SFRSTCR.SFRSTCR_PIDM AS PIDM,
    SATURN_SFRSTCR.SFRSTCR_TERM_CODE AS TERM, …

    FROM
    (((((SATURN_SFRSTCR INNER JOIN SATURN_STVRSTS ON SATURN_SFRSTCR.SFRSTCR_RSTS_CODE = SATURN_STVRSTS.STVRSTS_CODE) INNER JOIN CAPMGR_SZVTRMC ON (CAPMGR_SZVTRMC.SZVTRMC_TERM_CODE = SATURN_SFRSTCR.SFRSTCR_TERM_CODE) AND
    (SATURN_SFRSTCR.SFRSTCR_PIDM = CAPMGR_SZVTRMC.SZVTRMC_PIDM)) INNER JOIN SATURN_SMRPRLE GROUP BY SATURN_SFRSTCR.SFRSTCR_PIDM, SATURN_SFRSTCR.SFRSTCR_TERM_CODE, SATURN_SPRIDEN.SPRIDEN_ID, SATURN_SPRIDEN.SPRIDEN_LAST_NAME, …

    HAVING
    (((SATURN_SFRSTCR.SFRSTCR_TERM_CODE)=“201710”) AND
    ((SATURN_SPRIDEN.SPRIDEN_CHANGE_IND) Is Null) AND
    ((GENERAL_GOREMAL.GOREMAL_EMAL_CODE)=“PERS”) AND …

    ORDER BY SATURN_SFRSTCR.SFRSTCR_PIDM;

    Any help would be appreciated.
    Cheers. Bass



  • @Bacel-Younan

    did you try @Guido-Thelen s SQL Formatter?

    Cheers
    Claudia


Log in to reply