I have the following query, using MS SQL Server in a Wonderware (Industrial HMI) Historian application. The keywords beginning with 'ww' are Wonderware specific, wwResolution is getting the results every 24 hours:
SET QUOTED_IDENTIFIER OFF
SELECT * FROM OPENQUERY(INSQL,
"SELECT DateTime = convert(nvarchar, DateTime, 101) + ' 23:59:59.000',
[BarRoom_GASMETER.ACC], [DELAQ_GASMETER.ACC]
FROM WideHistory
WHERE wwRetrievalMode = 'Cyclic'
AND wwResolution = 86400000
AND wwVersion = 'Latest'
AND DateTime >= DateAdd(wk,-1,GetDate())
AND DateTime <= GetDate()")'
I want to try and format the query, so I do this:
format([BarRoom_GASMETER.ACC],'###,###,###,###,###.##') as 'Bar Room'
but I get 'Error Occurred'. Any suggestions on how I should be using format in this case? Thanks in advance for the answers. Added snapshot, you will have to save it locally to read it:
I think it has something to do with the way 'Quoted Identifier' is being handled.
QUOTED_IDENTIFIER
as I am able to turn that off as well and submit a similar query usingFORMAT(field, '###,##.#')
without a problem. – Solomon Rutzky#
to maybe1
to see if it works, just to see if it is the pound-sign itself that is the issue. If it is, it might need to be escaped somehow. – Solomon Rutzky