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).
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).