Error when formatting otherwise valid SQL with subqueries
opc.three
Posts: 17 New member
Repro:
The above is highlighted with errors when trying to format in version 7.0.0.62
USE tempdb; CREATE TABLE #tmp (id INT, name VARCHAR(100)) CREATE TABLE #tmp2 (id INT, name VARCHAR(100)) DELETE FROM #tmp WHERE id = ( SELECT id FROM #tmp2 WHERE name = 'abc' ) AND name = 'xyz';
The above is highlighted with errors when trying to format in version 7.0.0.62
Comments
My style document:
Thanks for the update!
SQL Prompt does not underline errors, that is done directly by SSMS' Intellisense. Sometimes these errors keep Prompt from doing something (like executing a single line), but that is because we take the error as something that needs to be fixed.
In this case it looks like SSMS is not detecting that the #tmp table has the columns "id" and "name" even though it was created directly above. If you put the table (#tmp) name in front of the column names (qualifying it), the tool will properly suggest a column.
If you try to use "Qualify Object names" it will error out because there are two tables that have the "id" and "name" column names and it will not (and cannot) guess which one you mean.
I hope that helps!
Warm Regards,
Technical Sales Engineer
Redgate Software
To confirm, I have SSMS Intellisense disabled when this occurs.
I hope this clarifies the issue.
Hopefully this issue is not limited to my machine. If you would try formatting my repro code with my style settings using my version of SQL Prompt hopefully you can see what I see.