Formatting issue Table Type

Hi Redgate Team,

SQL Prompt formats the Data Type like this

CREATE TYPE dbo.test AS TABLE
(
col1 int NOT NULL
  , col2 int NOT NULL
  , col3 int NOT NULL
  ,
  PRIMARY KEY NONCLUSTERED (
   col1
, col2
   )
  , INDEX NCL_ins_product_price_ID_status NONCLUSTERED (col2)
  ,
  UNIQUE (
col2
   , col1
)
);
GO

Neither the Primary Key nor the index or unique constraint is alligned.
It would be nice if you can fix this - thanks!



Answers

  • Hi @torsten.strauss

    Thanks for reaching out to us regarding this. My apology for the delay in responding to you.

    The formatting of the syntax will depend on what Active Style you have set in SQL Prompt. For example, If I format the syntax you provided with the Redgate default Active Style, then the outcome is almost identical to the screenshot you have provided.

    Are you using the default Active Style? Or are you using a custom Active Style?
    Kind regards

    Dan Jary | Redgate Software
    Have you visited our Help Center?
  • Hi Dan,

    I am using a custom style which I attached.

  • Dan_JDan_J Posts: 446 Silver 2
    Hi @torsten.strauss

    My apology for the delay in updating you on this!

    I am currently in discussions with my colleague on this. We just wanted to clarify that your desired formatting is shown in the screenshot your provided (below)?


    Kind regards

    Dan Jary | Redgate Software
    Have you visited our Help Center?
  • edited March 9, 2021 11:54AM
    Hi Dan

    Thanks for looking into this!

    The current formatted code with my attachted style looks like this:

    CREATE TYPE dbo.test AS TABLE
    (
    	col1 int NOT NULL
      , col2 int NOT NULL
      , col3 int NOT NULL
      ,
      PRIMARY KEY NONCLUSTERED (
    							   col1
    							 , col2
    						   )
      , INDEX NCL_ins_product_price_ID_status NONCLUSTERED (col2)
      ,
      UNIQUE (
    			 col2
    		   , col1
    		 )
    );
    GO

    I think it much better to align the code like this:

    CREATE TABLE dbo.test
    (
    	col1 int NOT NULL
      , col2 int NOT NULL
      , col3 int NOT NULL
      , PRIMARY KEY NONCLUSTERED (col1, col2)
      , INDEX NCL_ins_product_price_ID_status NONCLUSTERED (col2)
      , UNIQUE (col2, col1)
    );
    GO
    Torsten

  • Dan_JDan_J Posts: 446 Silver 2
    Hi @torsten.strauss

    My sincerest apology that it has taken so long to follow up on this!

    Unfortunately it does not appear to be possible to achieve the exact formatting you are after. However, after much tweaking of the style settings, I have been able to get quite close. Please see below:



    I am attaching the new style file that I hope will be useful to you.



    Kind regards

    Dan Jary | Redgate Software
    Have you visited our Help Center?
Sign In or Register to comment.