Hi there, I am having an issue with a script and I have got to the bottom of the troublesome part, but am unsure how to fix it.When I run the below code in New Query window in Management Studio it works as I expect. When I execute it in a view in order to save it to attach it to a refreshable spreadsheet it fails.The code is - SELECT MAX(WK.[TRASWEEK]) AS TRASWEEKFROM (SELECT DISTINCT [TRANS-WEEK] AS 'TRASWEEK' FROM dbo.[IH_RE-TNCY-TRANS] AS TRA6 WHERE ([TRANS-DATE] > GETDATE() - 42) AND ([ACCOUNT-TYPE] = 'IN') GROUP BY [TRANS-WEEK]) AS WK
When I run this in New Query. I get one result (correctly) of 27. 27 being the maximum week.When I paste this in the view and execute it it changes the code to - SELECT MAX('TRASWEEK') AS Expr1FROM (SELECT DISTINCT [TRANS-WEEK] AS 'TRASWEEK' FROM dbo.[IH_RE-TNCY-TRANS] AS TRA6 WHERE ([TRANS-DATE] > GETDATE() - 42) AND ([ACCOUNT-TYPE] = 'IN') GROUP BY [TRANS-WEEK]) AS WK
This pulls me back just a result of "Trasweek" and not the 27 I would have hoped for. Why is 2012 doing this. Why is it changing my code?Thanks