# SQL Query Tag Issue

**URL:** <https://forum.inductiveautomation.com/t/sql-query-tag-issue/10345>\
**Category:** Ignition\
**Created:** [August 14, 2015, 2:16pm UTC](https://forum.inductiveautomation.com/t/sql-query-tag-issue/10345 "2015-08-14T14:16:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RyanG](https://avatars.discourse-cdn.com/v4/letter/r/9de053/32.png) [@RyanG](https://forum.inductiveautomation.com/u/RyanG)\
**Post date:** [August 14, 2015, 2:16pm UTC](https://forum.inductiveautomation.com/t/sql-query-tag-issue/10345/1 "2015-08-14T14:16:39Z")

</div>

So I’m trying to execute a stored procedure in a query tag but it does not work and just returns a null value. The query should return only a single number. For some reason I am able to execute the stored procedure if I bind it to a property value such as a PV for a analog indicator but does not work for Query Tags. I’m also able to run a basic select statement through a query tag but cannot get it to execute a stored procedure. Is there any reason why I am unable to execute a stored procedure from a SQL Query Tag or what could I be possibly missing?

Thanks,

---

<div class="post-metadata">

**Author:** ![DougSN](https://avatars.discourse-cdn.com/v4/letter/d/a9adbd/32.png) [@DougSN](https://forum.inductiveautomation.com/u/DougSN)\
**Post date:** [February 8, 2016, 10:14pm UTC](https://forum.inductiveautomation.com/t/sql-query-tag-issue/10345/2 "2016-02-08T22:14:16Z")

</div>

I’m running into the same issue at the moment. I see you didn’t get any replies on the forum, were you able to figure it out for yourself? Thanks!

---

<div class="post-metadata">

**Author:** ![Kraenbring](https://avatars.discourse-cdn.com/v4/letter/k/f4b2a3/32.png) [@Kraenbring](https://forum.inductiveautomation.com/u/Kraenbring)\
**Post date:** [February 12, 2016, 1:47pm UTC](https://forum.inductiveautomation.com/t/sql-query-tag-issue/10345/3 "2016-02-12T13:47:02Z")

</div>

Check to make sure you have this line at the beginning of the stored procedure:  
SET NOCOUNT ON;

Otherwise it returns two datasets, the first being a count of records affected, the second being your actual data. Here’s a sp i just created to test:

[code]CREATE PROCEDURE QueryTagResult  
@x int  
,@y int

AS  
BEGIN  
SET NOCOUNT ON;

```
select @x + @y as 'value'

```

END  
GO[/code]

And for my SQL Query Tag, I have this as my statement:

```auto
execute QueryTagResult 2,3
```

Make sure the Query Type is set to “Select”  
Hope that helps!

---

<div class="post-metadata">

**Author:** ![DougSN](https://avatars.discourse-cdn.com/v4/letter/d/a9adbd/32.png) [@DougSN](https://forum.inductiveautomation.com/u/DougSN)\
**Post date:** [February 12, 2016, 4:04pm UTC](https://forum.inductiveautomation.com/t/sql-query-tag-issue/10345/4 "2016-02-12T16:04:16Z")

</div>

Thanks for your reply! I was sure I had tried that before, but it is working now. Have a great weekend!
