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

Breaking bug in SQL Prompt

SELECT


Hi!

I just ran into a dangerous bug in SQL Prompt, where it changes my code instead of merely reformatting it. I am running 9.5.12.10845, which I think is the latest build. The repro code below runs on the "ReportServer" database that is standard installed for every SQL instance that has SSRS configured.

First, copy/paste the code above (the repro is simplified as much as possible, the original query is more useful). The idea is to ensure that linked reports are sorted immediately after the report they link to, even if they have a different name. Linked reports that, somehow, got orphaned are sorted last. (And yes, I know that reports with a name starting with Z would break this; not relevant for this issue).

Next, hit Ctrl-Y - Ctrl-Z to activate the magic of SQL Prompt. It will (in my case) not change the formatting since the snippet above already uses my preferred formatting guidelines. But ... it DOES change the WHERE clause in the subquery. After reformatting, it reads WHERE Catelog2.Item = Catalog2.LinkSourceID. Instead of a correlated subquery, it is now a normal subquery. And it returns nothing, since LinkSourceID can never be equal to ItemID.

End result: All linked reports sort last, as if they are all orphaned (which they are not).

HugoKornelis
0

Comments

2 comments

  • Alex B
    Hi @HugoKornelis,

    It's not breaking for me.  When I format using default options and default formatting style with nothing else in a new query window, it doesn't change the "catalog.LinkSourceID" portion.

    Do you have anything else in the query window?  I can also reach out via a support ticket to get the style and settings you are using to see if there's something in there that is causing the issue.

    Kind regards,
    Alex
    Alex B
    0
  • Alex B
    Oh and also what SSMS and SQL Server version is this with?
    Alex B
    0

Add comment

Please sign in to leave a comment.