How can we help you today? How can we help you today?

Formatting problem

Hi,
I have encountered a problem when formatting code that uses AT TIME ZONE. 
When I format code like this:

SELECT  CAST(X.CreatedDate AT TIME ZONE 'UTC' AT TIME ZONE X.TimeZone AS datetime) AS CreatedDate
FROM (SELECT  GETUTCDATE() AS CreatedDate, 'E. Australia Standard Time' AS TimeZone)  X;

SELECT  CAST(((X.CreatedDate AT TIME ZONE 'utc' ) AT TIME ZONE X.TimeZone) AS datetime) AS CreatedDate
FROM (SELECT  GETUTCDATE() AS CreatedDate, 'E. Australia Standard Time' AS TimeZone)  X;

The result is this, where the column alias is qualified with the table alias X :

SELECT  CAST(((X.CreatedDate AT TIME ZONE 'utc' ) AT TIME ZONE X.TimeZone) AS datetime) AS X.CreatedDate
FROM (SELECT  GETUTCDATE() AS CreatedDate, 'E. Australia Standard Time' AS TimeZone)  X;


When using a different column alias, the problem does not occur.

Thanks.

Chris.
ChrisYoung
0

Comments

6 comments

  • DustinM
    Hi Chris,

    Could you confirm which version of SSMS and SQL Prompt you are currently using?

    Best,

    Dustin
    DustinM
    0
  • ChrisYoung
    Hi Dustin,

    I'm using SSMS 18.11.1 and SQL Prompt 10.12.1.28146.

    ChrisYoung
    0
  • DustinM
    Hi Chris,

    We were able to reproduce the formatting problem as described.

    We have escalated this to our dev team for further investigation and will follow up once more information has been made available.

    Best,

    Dustin

    DustinM
    0
  • DustinM
    Hi Chris,

    Would you be able to update to the most recent version of SQL Prompt v10.12.3 and see if the issue is still occurring?

    Best,

    Dustin
    DustinM
    0
  • ChrisYoung
    Dustin,

    I have updated to the latest version but it did not resolve the problem.



    Regards,

    Chris
    ChrisYoung
    0
  • DustinM
    Hi Chris,

    Thank you for checking that, we may need more information on this one since we can no longer replicate this scenario on our end and will be reaching out via email.

    Best,

    Dustin
    DustinM
    0

Add comment

Please sign in to leave a comment.