Aggregate Functions wrongly put in square brackets
I think I 've found a bug...
If you Format this SQL
DECLARE @Translations TABLE
(
[FundTypeId] INT NOT NULL ,
[ColumnName] NVARCHAR(128) NULL ,
[ColumnValue] NVARCHAR(256) NULL ,
[InsertedAt] DATETIME NULL ,
[InsertedBy] NVARCHAR(256) NULL ,
[LastUpdatedAt] DATETIME NULL ,
[LastUpdatedBy] NVARCHAR(256) NULL ,
PRIMARY KEY ( [FundTypeId] )
);
SELECT *
FROM ( SELECT [pt].[FundTypeId] ,
[pt].[FundType] ,
[pt].[Comment] ,
[pt].[InsertedAt] ,
[pt].[InsertedBy] ,
[pt].[LastUpdatedAt] ,
[pt].[LastUpdatedBy]
FROM @Translations AS [tmp] PIVOT ( MAX([ColumnValue]) FOR [tmp].[ColumnName] IN ( [FundType], [Comment] ) ) AS [pt]
) AS [tmp];
... it will break the code as the MAX function of the PIVOT is put into square brackets...
Regards
Ralf
1
vote
![](https://secure.gravatar.com/avatar/e4749a618c3777e79761e2cf8bd4e580?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)
We’ve just released a new build of Prompt ( 6.5.0.332) which should have a fix for this. You can get the latest version from our website http://www.red-gate.com/products/sql-development/sql-prompt/