# Save Tag to SQL on change of state

**URL:** <https://forum.inductiveautomation.com/t/save-tag-to-sql-on-change-of-state/110754>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [September 18, 2025, 2:04pm UTC](https://forum.inductiveautomation.com/t/save-tag-to-sql-on-change-of-state/110754 "2025-09-18T14:04:53Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![bshriner](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@bshriner](https://forum.inductiveautomation.com/u/bshriner)\
**Post date:** [September 18, 2025, 2:04pm UTC](https://forum.inductiveautomation.com/t/save-tag-to-sql-on-change-of-state/110754/1 "2025-09-18T14:04:53Z")

</div>

Hey y’all,

I am new to ignition and SQL in general. I have been able to create the ignition dashboard that I need, but now I need to save data to a SQL database. I have a tag folder that holds all the tags I need to put into the SQL database (see below). I only need to put this data into SQL once a different tag changes from 0 to 1.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/a/ea4df4f7132f25511785b1331f0c9255956e6e27.png)

I am not sure exactly how to tackle this problem with my very limited SQL and Ignition knowledge. Do I need to write a script? Do I need to manually create a SQL table with a column for each tag? Or can ignition automatically do this for me?

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [September 18, 2025, 2:32pm UTC](https://forum.inductiveautomation.com/t/save-tag-to-sql-on-change-of-state/110754/2 "2025-09-18T14:32:52Z")

</div>

Do you have the SQL Bridge module installed?

---

<div class="post-metadata">

**Author:** ![bshriner](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@bshriner](https://forum.inductiveautomation.com/u/bshriner)\
**Post date:** [September 18, 2025, 2:39pm UTC](https://forum.inductiveautomation.com/t/save-tag-to-sql-on-change-of-state/110754/3 "2025-09-18T14:39:03Z")

</div>

Yes

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [September 18, 2025, 2:46pm UTC](https://forum.inductiveautomation.com/t/save-tag-to-sql-on-change-of-state/110754/4 "2025-09-18T14:46:47Z")

</div>

You'll want to look into [Transaction Groups](https://www.docs.inductiveautomation.com/docs/8.3/ignition-modules/sql-bridge-transaction-groups).

As someone who knows SQL I prefer to write my own queries, but Transaction Groups were created for just this kind of thing.

---

<div class="post-metadata">

**Author:** ![bshriner](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@bshriner](https://forum.inductiveautomation.com/u/bshriner)\
**Post date:** [September 18, 2025, 2:52pm UTC](https://forum.inductiveautomation.com/t/save-tag-to-sql-on-change-of-state/110754/5 "2025-09-18T14:52:37Z")

</div>

Thank you!

I think this is exactly what I was trying to find. Now I just need to wait for the trigger to ensure that it is working properly.

---

<div class="post-metadata">

**Author:** ![bshriner](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@bshriner](https://forum.inductiveautomation.com/u/bshriner)\
**Post date:** [September 18, 2025, 5:15pm UTC](https://forum.inductiveautomation.com/t/save-tag-to-sql-on-change-of-state/110754/6 "2025-09-18T17:15:23Z")

</div>

So now that I have been watching it for a bit it isn’t triggering when the tag i am looking at changes. I was trying to mess with it by forcing the tag to 1, but that wasnt working. When I change the trigger to when the tag = 0 it works though. So I know that it is able to write to my SQL, just not when I need it to.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/d/7dec95f688ba918981cc436a2fcd798cb4f27e95.png)

Looking at it now I am not quite sure what the difference is between the Tags to watch for change and the Trigger on item

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [September 18, 2025, 5:29pm UTC](https://forum.inductiveautomation.com/t/save-tag-to-sql-on-change-of-state/110754/7 "2025-09-18T17:29:36Z")

</div>

Are you sure you want `Only evaluate when values have changed`? If the values you're recording haven't changed, then the trigger won't cause them to be written.

---

<div class="post-metadata">

**Author:** ![bshriner](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@bshriner](https://forum.inductiveautomation.com/u/bshriner)\
**Post date:** [September 18, 2025, 5:36pm UTC](https://forum.inductiveautomation.com/t/save-tag-to-sql-on-change-of-state/110754/8 "2025-09-18T17:36:26Z")

</div>

Im pretty sure this is what I want. I am looking at a specific tag and once it changes I want to write my values to the SQL Table. I dont want them written UNLESS that tag has changed from a 0 to a 1

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [September 18, 2025, 5:42pm UTC](https://forum.inductiveautomation.com/t/save-tag-to-sql-on-change-of-state/110754/9 "2025-09-18T17:42:35Z")

</div>

That option refers to the tags being written, not the trigger. And it overrides the trigger, meaning they won't write if they haven't changed.

The UI is confusing, because the tab name is "Trigger" but there's a specific option you're using for executing "on a trigger." When you don't use that, the trigger becomes a change in the values of one or more of the tags that are being written, _if_ you have that option checked.

Someone else can correct me if I'm wrong about this, but I have used Transaction Groups in the past and that is my recollection of how it works.

---

<div class="post-metadata">

**Author:** ![bshriner](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@bshriner](https://forum.inductiveautomation.com/u/bshriner)\
**Post date:** [September 18, 2025, 6:02pm UTC](https://forum.inductiveautomation.com/t/save-tag-to-sql-on-change-of-state/110754/10 "2025-09-18T18:02:41Z")

</div>

That shouldn’t matter for my case because the tags get changed every cycle.

Either way, I unchecked that though and it still isn’t triggering.

A potential issue may be in my Execution scheduling, I have it for 1 second. Do you know if this means that it checks the tag every 1 second for a change?

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [September 18, 2025, 7:28pm UTC](https://forum.inductiveautomation.com/t/save-tag-to-sql-on-change-of-state/110754/11 "2025-09-18T19:28:36Z")

</div>

That may be the case, I'm not sure, but it would explain why you don't always see the trigger happening if the trigger tag value goes back to 0 so quickly. If that's the case, you could create a secondary tag that is set to 1 when that one is (via change script), assign that as the trigger, and then use the `Write handshake on success` option to set it back to 0 when the trigger is invoked.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [September 18, 2025, 7:44pm UTC](https://forum.inductiveautomation.com/t/save-tag-to-sql-on-change-of-state/110754/12 "2025-09-18T19:44:10Z")

</div>

You definately do not want `Only evaluate when values have changed` checked. You are only interested in executing when the trigger tag has changed. _If_ that option is _checked_ then and only then will it look at the value of your trigger.

Not what you want.

> [@bshriner](#):
>
> That shouldn’t matter for my case because the tags get changed every cycle.

Actually, it could matter, depending on what you have slected as the `Tags to watch for change`.

> [@bshriner](#):
>
> Do you know if this means that it checks the tag every 1 second for a change?

Assuming you are using the `Timer` option, 1 second means OPC tags are subscribed to at a 1 sec rate.

Its hard to tell what may be the issue may be from what you have showed us. I am assuming that you are using a basic transaction group, and that you have only OPC Group Items.

Tip:  
On the Options tab, you should probably make certain that you have the OPC data mode set to Read. This will tell the trasaction group to first read the values at execution before continuing the execution and writing them to the database.
