WHERE-clause alignments

GHauanGHauan Posts: 13 New member
Hi.

Is there a way to have SQL Prompt align each element after WHERE on the same column as WHERE? Like this:

SELECT *
FROM dbo.Anlegg
WHERE AnleggsId = 1
AND StartDate <= getdate()
AND StopDate IS NULL;

The way it is now, I only get it formatted with the AND part aligned with the Anleggsid in WHERE-line.
(I tried to show how it was in this post, but the indentation was removed when posting.)

Is there an option setting to fix this?
Tagged:

Comments

  • Hi GHauan,

    Thanks for the suggestion. You can insert code tags on here to keep your text formatted.

    Could I confirm you want to style your code like this? Are you using the new formatting options (enabled in experimental features)?
    SELECT *
    FROM dbo.Anlegg
    WHERE AnleggsId = 1
      AND StartDate <= getdate()
      AND StopDate IS NULL;
    

    Best wishes,

    Michael Clark
    Technical Lead, SQL Prompt
    Michael Clark
    Technical Lead, SQL Monitor
  • GHauanGHauan Posts: 13 New member
    Hi Michael

    The way I want it to be, is the way it is in my original post. Meaning that the AND start on same column as the WHERE:
    SELECT *
    FROM dbo.Anlegg
    WHERE Anleggsid = 1
    AND StartDate <= getdate()
    AND StopDate IS NULL;
    

    I have not tried the experimental features.

    The way it is formatted today is like this (and this is not how I want it):
    SELECT *
    FROM dbo.Anlegg
    WHERE 	Anleggsid = 1
           AND StartDate <= getdate()
           AND StopDate IS NULL;
    
  • Hi GHauan,

    We support the style you want as default with our new formatting styles.

    You can turn these on by selecting "SQL Prompt > Options... > Labs > Experimental Features > Use new formatting styles"

    Please let us know if you have any trouble :smile:

    Thanks,
    Michael
    Michael Clark
    Technical Lead, SQL Monitor
  • Hello guys,

    I am using SQL Prompt 9.2.2 and the alignment of the where clause as GHauan had commented is not yet available.

    In version 9.2.2, I tried to enable the option "SQL Prompt> Options ...> Labs> Experimental Features> Use new formatting styles" as Michael commented, but does not have this option.

    Do you have any idea when this option will be implemented?

    Example

    select *
    from table
    where condition1 = 1
        and condition2 = 2

    Thank you


  • LarryBoyntonLarryBoynton Posts: 1 New member
    I am trying to setup my style using 10.0.6 and can't seem to get the AND to line up with the WHERE.  What setting would I use to get the following:

    SELECT *
    FROM table AS t
    WHERE t.col1=1
    AND t.col2=2;

    I had it before, but had to rebuild my machine and lost my old style. 

Sign In or Register to comment.