How to align datatypes with spacing in a table, stored procedure, or variable declarations?

ggeier2ggeier2 Posts: 10 Bronze 1
edited March 8, 2023 3:16PM in SQL Prompt
How can I align data types? For example, SQL Prompt currently formats this table as:

<div>create table dbo.some_table</div><div>(</div><div>&nbsp; &nbsp; some_id int identity(1, 1) primary key clustered</div><div>&nbsp; &nbsp;,some_name varchar(128)</div><div>&nbsp; &nbsp;,some_other_name varchar(1000)</div><div>)</div>

I'd like for it to format it as:

<div>create table dbo.aligned_table</div><div>(</div><div>&nbsp; &nbsp; some_id&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int identity(1, 1) primary key clustered</div><div>&nbsp; &nbsp;,some_name&nbsp; &nbsp; &nbsp; &nbsp;varchar(128)</div><div>&nbsp; &nbsp;,some_other_name varchar(1000)</div><div>)</div>

Is this possible?

edit: Not sure why the code isn't formatting properly after I published the question.
Tagged:

Answers

  • Hi @ggeier2

     Thank you for reaching out on the Redgate forums

     Sorry that the formatting didn't come out as expected - I took your html code and believe the difference you outlined is the indentation of code within the parentheses?

    create table dbo.some_table
    (
    &nbsp; &nbsp; some_id int identity(1, 1) primary key clustered
    &nbsp; &nbsp;,some_name varchar(128)
    &nbsp; &nbsp;,some_other_name varchar(1000)
    )

    ---

    create table dbo.aligned_table
    (
    some_id int identity(1, 1) primary key clustered
    ,some_name varchar(128)
    ,some_other_name varchar(1000)
    )


    If so it may be a case of editing the following setting in your style

     

    Schema (DDL) > Indent parentheses contents

    Example below with your sample code indented & un-indented

     

     

    Is this the alignment change you were looking to make? 

     

    Jon Kirkwood | Technical Support Engineer | Redgate Software
  • ggeier2ggeier2 Posts: 10 Bronze 1
    Thank you for the response. What I was looking for was a little different. I took a screenshot so it can be seen easier:


Sign In or Register to comment.