Use Object Definition Case possible bug
dhall
Posts: 5 Bronze 1
When there is a single SQL statement including a temp table and a permanent table, both of which have the same column name but different case, formatting the statement with the "Use object definition case" feature on will change the case of the temp table to match that of the permanent table.
Here is a simplified example:
SELECT OrderID
INTO dbo.#OrdersTable
FROM dbo.OrdersTable;
SELECT *
FROM dbo.PharmacyTable AS P
INNER JOIN dbo.#OrdersTable AS O ON P.OrderId = O.OrderID;
When formatting this code with the "Use object definition case" feature on in the Format/Styles/Case menu, it will turn O.OrderID into O.OrderId, which causes an error when executing the statement. When using the permanent OrdersTable instead of the temporary #OrdersTable in the second statement, the O.OrderID column stays as is. Thank you for looking into this.
Here is a simplified example:
SELECT OrderID
INTO dbo.#OrdersTable
FROM dbo.OrdersTable;
SELECT *
FROM dbo.PharmacyTable AS P
INNER JOIN dbo.#OrdersTable AS O ON P.OrderId = O.OrderID;
When formatting this code with the "Use object definition case" feature on in the Format/Styles/Case menu, it will turn O.OrderID into O.OrderId, which causes an error when executing the statement. When using the permanent OrdersTable instead of the temporary #OrdersTable in the second statement, the O.OrderID column stays as is. Thank you for looking into this.
Comments
Thanks for flagging this up! The problem seems to be that when temporary tables are qualified with a schema we don't resolve them correctly.
I'll have a look at this when I'm back in the office on Tuesday (my colleague is out on vacation for two weeks and I'm out on business on Monday).
Thank you for your patience, and please do tell us if you find any more issues!
Best regards,
David
Sorry for the lack of a reply yesterday! This is incorrect behaviour for Prompt and we'll try and get this fixed for you.
Best regards,
David
Apologies for any inconvenience caused. I've got a private build which should fix the issue.
Please let me know if you have any problems with it.
Best regards,
David