Wonderware Historian SQL Query

First of All I want to say thank you to @kcollins1 and @PGriffith for leading me to the right answer. The issue is with the double quotes and single quotes. I am not sure how it worked originally but it did. Then it stopped working. The double quotes can only have 128 characters in it. Once I changed the variables to double quotes and the overall string to single quotes it worked. Thanks to all for the help.

SELECT * FROM OPENQUERY(INSQL, 'SELECT DateTime, SysTimeSec, SysTimeMin
 FROM WideHistory
 WHERE wwRetrievalMode = "Cyclic"
 AND wwResolution = 1000
 AND wwQualityRule = "Extended"
 AND wwVersion = "Latest"
 AND DateTime >= DateAdd(hh,-1,GetDate())
 AND DateTime <= GetDate()') order by DateTime asc
1 Like