# SQL CTE Not Returning Results

**URL:** <https://forum.inductiveautomation.com/t/sql-cte-not-returning-results/36942>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [July 22, 2020, 1:34pm UTC](https://forum.inductiveautomation.com/t/sql-cte-not-returning-results/36942 "2020-07-22T13:34:12Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [July 22, 2020, 2:25pm UTC](https://forum.inductiveautomation.com/t/sql-cte-not-returning-results/36942/2 "2020-07-22T14:25:21Z")

</div>

Do you get any errors when you run this in the DB Browser?

I suspect Ignition is interpreting your query as an update and not a select.

You could try this solution

> [@Microsoft SQL Server - "Result set was generated for update"](http://forum.inductiveautomation.com/t/microsoft-sql-server-result-set-was-generated-for-update/2499):
>
> If using Ignition (or FactorySQL/PMI, for that matter) with SQL Server and you run into the following error in various places: you need to turn off the “no count” option for the server. It appears that the different versions of SQL Server are inconsistent as to whether it is on by default. To change it: Go into the SQL Server management console Right-click on the server and select “properties”. Select “connections” Under “Default Connection Options”, turn off “no count”. The change will on…

The solution below suggests running runQuery which you are doing so if the No Count Off solutions doesn't work for you then you'll probably have to wrap it in a Stored Procedure as recommended below or use a View and call that.

> [@A result set was generated for update - SQL Query](http://forum.inductiveautomation.com/t/a-result-set-was-generated-for-update-sql-query/6338/2):
>
> Where are you trying to run it from? Wherever it is, it is trying to run it as an “update”, when you really want it to run like a select. You’ll likely need to use the [system.db.runQuery](http://inductiveautomation.com/support/usermanuals/ignition/system_db_runquery.htm) scripting function or something similar. And in that case, it’ll probably be easier to wrap it up in a stored procedure and just call that. Regards,

---

_[View the full topic](https://forum.inductiveautomation.com/t/sql-cte-not-returning-results/36942)._
