In the sample query below [object_id] and [type_desc] are underlined in green because they're unqualified. SQL Prompt does not automatically add the [p]. aliases and if I manually add them and then format it strips them out. Also, in the first SELECT if I remove the [s] and [pvt] aliases and then format, it puts [s] back but not [pvt]. SQL Prompt 11.0.8 on Azure SQL database.
SELECT
[s].[name]
, [pvt].[SYSTEM_TABLE]
, [pvt].[USER_TABLE]
, [pvt].[VIEW]
FROM
(
SELECT
[o].[schema_id]
, [o].[object_id]
, [o].[type_desc]
FROM [sys].[objects] AS [o]
) AS [p]
PIVOT
(
COUNT([object_id])
FOR [type_desc] IN ([SYSTEM_TABLE], [USER_TABLE], [VIEW])
) AS [pvt]
JOIN [sys].[schemas] AS [s]
ON [s].[schema_id] = [pvt].[schema_id]
ORDER BY 1;
In the sample query below [object_id] and [type_desc] are underlined in green because they're unqualified. SQL Prompt does not automatically add the [p]. aliases and if I manually add them and then format it strips them out. Also, in the first SELECT if I remove the [s] and [pvt] aliases and then format, it puts [s] back but not [pvt]. SQL Prompt 11.0.8 on Azure SQL database.
SELECT[s].[name], [pvt].[SYSTEM_TABLE], [pvt].[USER_TABLE], [pvt].[VIEW]FROM(SELECT[o].[schema_id], [o].[object_id], [o].[type_desc]FROM [sys].[objects] AS [o]) AS [p]PIVOT(COUNT([object_id])FOR [type_desc] IN ([SYSTEM_TABLE], [USER_TABLE], [VIEW])) AS [pvt]JOIN [sys].[schemas] AS [s]ON [s].[schema_id] = [pvt].[schema_id]ORDER BY 1;