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

SQL Prompt column qualifications dropped when a table alias is used

This bug has existed for as for as long as I have been using SQL Prompt:

CREATE TABLE dbo.Foo (FooId INT PRIMARY KEY);
CREATE TABLE dbo.Foo2 (FooId INT PRIMARY KEY);
CREATE TABLE dbo.Bar (BarId INT PRIMARY KEY);

-- without aliases, columns are still qualified
SELECT NULL 
   FROM dbo.Foo 
  INNER JOIN dbo.Bar ON Bar.BarId = Foo.FooId;

-- after formatting alias qualifiers in ON clause are dropped
SELECT NULL
   FROM dbo.Foo AS _Foo 
  INNER JOIN dbo.Bar AS _Bar ON BarId = _Foo.FooId
  INNER JOIN dbo.Foo2 AS _Foo2 ON _Foo2.FooId = _Foo.FooId;

DROP TABLE dbo.Foo;
DROP TABLE dbo.Foo2;
DROP TABLE dbo.Bar;

adam1100
0

Comments

7 comments

  • Eddie D
    Hi, thank you for your forum post.

    What version of SQL Prompt are you using? Also what version of SSMS are you using?
     I ask these questions as I am unable to replicate the reported problem using SSMS 18.4 and SQL Prompt V10.1.4.14671 installed on my test system. I know that I am version behind the current latest versions of SSMS and SQL Prompt.

    Many Thanks
    Eddie
    Eddie D
    0
  • adam1100
    Hi Eddie, I'm on SQL Prompt version 10.1.5.14730, and SQL Server Management Studio 15.0.18206.0 (SSMS v18.4)

    adam1100
    0
  • Eddie D
    Hi adam1100,
    After upgrading my SQL Prompt installation to V10.1.5.14730, I am now able to replicate the reported problem.

    I have submitted a bug report.  I will update this post when I receive further news.

    Many Thanks
    Eddie
    Eddie D
    0
  • adam1100
    Thanks Eddie.  Appreciate it
    adam1100
    0
  • Eddie D
    Hi adam1100,

    Can you please enable the following option (SQL Prompt menu -> Options) highlighted by the red rectangle in the following screen shot?


    With this option enabled, I can no longer replicate the reported fault symptoms.

    Also can you ensure that the Qualify column names with aliases" (SQL Prompt ->Options-> Inserted code ->Qualification) is checked as well.

    I hope turning on the above options resolves the problem for you.

    Many Thanks
    Eddie
    Eddie D
    0
  • adam1100
    Eddie, that worked, thank you very much.
    adam1100
    0
  • Eddie D
    Hi adam1100,
    Excellent news that the option resolves the problem.
    The congratulations should go to my colleagues in development team, who made me aware of the option that I embarrassingly missed.

    Many Thanks
    Eddie
    Eddie D
    0

Add comment

Please sign in to leave a comment.