# Sql queries containing temp tables or table variables

**URL:** <https://forum.inductiveautomation.com/t/sql-queries-containing-temp-tables-or-table-variables/6195>\
**Category:** Ignition\
**Created:** [April 10, 2013, 10:50am UTC](https://forum.inductiveautomation.com/t/sql-queries-containing-temp-tables-or-table-variables/6195 "2013-04-10T10:50:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jose.granero](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jose.granero/32/11190_2.png) [@jose.granero](https://forum.inductiveautomation.com/u/jose.granero)\
**Post date:** [April 10, 2013, 10:50am UTC](https://forum.inductiveautomation.com/t/sql-queries-containing-temp-tables-or-table-variables/6195/1 "2013-04-10T10:50:51Z")

</div>

I’m experimenting problems when executing SQL queries containing either temp tables or variable tables, this queries run perfectly on the SQL server, however in Ignition I get this message:

Exception: Error running query:  
SQLQuery(query=

CREATE TABLE #kk(t\_stamp datetime, EA\_FUERZA\_P5 bigint,Incremento bigint)  
INSERT INTO #kk SELECT t\_stamp,EA\_FUERZA\_P5,Incremento=  
LEAD(EA\_FUERZA\_P5) OVER (ORDER BY t\_stamp)-EA\_FUERZA\_P5  
FROM Consumos

SELECT DATEPART(Hour,t\_stamp),SUM(Incremento)  
FROM #kk  
WHERE DAY(t\_stamp)=DAY(‘2013-4-9’)  
GROUP BY DATEPART(Hour,t\_stamp)

DROP TABLE #kk, database=TORRELAGUNA\_HIST)@5000ms  
On: Main Window.Root Container.Table 1.data  
caused by GatewayException: La instrucción no devolvió un conjunto de resultados.  
caused by SQLServerException: La instrucción no devolvió un conjunto de resultados.

Ignition v7.5.6 (b1317)  
Java: Oracle Corporation 1.7.0\_17

I need to clarify as soon as possible if these tables are supported in Ignition, since they’re vital for our development.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 10, 2013, 3:50pm UTC](https://forum.inductiveautomation.com/t/sql-queries-containing-temp-tables-or-table-variables/6195/2 "2013-04-10T15:50:54Z")

</div>

They are supported. There is a difference of running that query in Ignition versus the database. You should try to make a stored procedure for that function. You might be able to put:`SET NOCOUNT ON`at the top of your query.
