Formatting issue

ogrishmanogrishman Posts: 81 Bronze 4
edited December 19, 2016 4:45AM in SQL Prompt
I have a piece of code:
SELECT
    OBJECT_SCHEMA_NAME(c.object_id, DB_ID())schema_name,
    OBJECT_NAME(c.object_id)                object_name,
    c.name                                  column_name,
    t.name,
    t.name + CASE
                 WHEN t.name IN ('char', 'varchar', 'nchar', 'nvarchar') THEN
                     '(' + CASE
                               WHEN c.max_length = -1 THEN
                                   'max'
                               ELSE
                                   CONVERT(VARCHAR(4),
                                       CASE
                                           WHEN t.name IN ('nchar', 'nvarchar') THEN
                                               c.max_length / 2
                                           ELSE
                                               c.max_length
                                       END)
                           END + ')'
                 WHEN t.name IN ('decimal', 'numeric') THEN
                     '(' + CONVERT(VARCHAR(4), c.precision) + ',' + CONVERT(VARCHAR(4), c.scale) + ')'
                 ELSE
                     ''
             END                            ddl_name,
    c.max_length                            max_length_in_bytes,
    c.precision,
    c.scale,
    c.is_nullable,
    ISNULL(i.is_primary_key, 0)             is_primary_key
  FROM
    sys.columns c
    INNER JOIN sys.types t
        ON c.user_type_id = t.user_type_id
    LEFT OUTER JOIN sys.index_columns ic
        ON ic.object_id = c.object_id
           AND ic.column_id = c.column_id
    LEFT OUTER JOIN sys.indexes i
        ON ic.object_id = i.object_id
           AND ic.index_id = i.index_id
 -- WHERE c.object_id = OBJECT_ID('mytable')
 ORDER BY
    schema_name,
    object_name,
    column_name;

It looks like this after formatted using SQL Prompt:

2016-12-16_11-06-23.png

I configured SQL Prompt to align the aliases. However I want to know if there is a way to let aliases have at least one space before them.

Thanks.

Comments

Sign In or Register to comment.