SQL Prompt column qualifications dropped when a table alias is used

adam1100adam1100 Posts: 4 New member
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;

Best Answer

  • Eddie DEddie D Posts: 1,803 Rose Gold 5
    Answer ✓
    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 Davis
    Senior Product Support Engineer
    Redgate Software Ltd
    Email: support@red-gate.com

Answers

Sign In or Register to comment.