# Query tag error relating to "...OLE DB provider "INSQL"

**URL:** <https://forum.inductiveautomation.com/t/query-tag-error-relating-to-ole-db-provider-insql/68751>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 18, 2023, 7:46pm UTC](https://forum.inductiveautomation.com/t/query-tag-error-relating-to-ole-db-provider-insql/68751 "2023-01-18T19:46:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Footuck](https://avatars.discourse-cdn.com/v4/letter/f/ad7895/32.png) [@Footuck](https://forum.inductiveautomation.com/u/Footuck)\
**Post date:** [January 18, 2023, 7:46pm UTC](https://forum.inductiveautomation.com/t/query-tag-error-relating-to-ole-db-provider-insql/68751/1 "2023-01-18T19:46:32Z")

</div>

I have two instances of a UDT tag that are the same except the parameter values. One of them works as it should. The other one throws an error on one of the query tags within the instance that pulls data from **WonderWare Historian** as follows:

Error running query:  
SELECT TOP 1 \* FROM OPENQUERY(INSQL, 'SELECT DateTime = convert(nvarchar, DateTime, 21), {AirPV} / {AirCV} [BurnerControl\_Air], {GasPV} / {GasCV} [BurnerControl\_Gas]  
FROM WideHistory WHERE wwRetrievalMode = ''Cyclic'' AND wwCycleCount = 1 AND wwVersion = ''Latest'' AND DateTime \>= DateAdd(mi,-1,GetDate()) AND DateTime \<= GetDate()')

**An error occurred while preparing the query**"SELECT DateTime = convert(nvarchar, DateTime, 21), {AirPV} / {AirCV} [BurnerControl\_Air], {GasPV} / {GasCV} [BurnerControl\_Gas]  
FROM WideHistory WHERE wwRetrievalMode = 'Cyclic' AND wwCycleCount = 1 AND wwVersion = 'Latest' AND DateTime \>= DateAdd(mi,-1,GetDate()) AND DateTime = GetDate()"  
**for execution against OLE DB provider "INSQL" for linked server "INSQL".**

I've confirmed that the QueryParams are correct in both instances and that the data exists in WW Historian.

Thoughts?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 19, 2023, 1:40am UTC](https://forum.inductiveautomation.com/t/query-tag-error-relating-to-ole-db-provider-insql/68751/2 "2023-01-19T01:40:51Z")

</div>

You will probably need to reach out to [Wonderware support](https://www.aveva.com/en/support-and-success/support-contact/wonderware/) for this one. Looking through their forum, it looks like they've seen this one a few times before.
