# Write SQL Tabke

**URL:** <https://forum.inductiveautomation.com/t/write-sql-tabke/4727>\
**Category:** Archived Topics\
**Created:** [June 28, 2012, 5:47pm UTC](https://forum.inductiveautomation.com/t/write-sql-tabke/4727 "2012-06-28T17:47:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Messias](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@Messias](https://forum.inductiveautomation.com/u/Messias)\
**Post date:** [June 28, 2012, 5:47pm UTC](https://forum.inductiveautomation.com/t/write-sql-tabke/4727/1 "2012-06-28T17:47:29Z")

</div>

Hi, I need writing values that I’m reading online “PLC” to SQL table.  
Every time my table was modified, I have debouts correct scripts for this function.

Tables= Pressure Process  
Column1= PS1  
Column2= PS2

Thanks

---

<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:** [June 28, 2012, 6:27pm UTC](https://forum.inductiveautomation.com/t/write-sql-tabke/4727/2 "2012-06-28T18:27:39Z")

</div>

You should use a transaction group to write values from the PLC to the database. You can use the standard group setting the mode from OPC-\>DB. You just need to map each PLC tag to a column in the database table. If you want bi-directional synchronization you can set the mode to Bi-Directional OPC Wins.

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [June 28, 2012, 6:30pm UTC](https://forum.inductiveautomation.com/t/write-sql-tabke/4727/3 "2012-06-28T18:30:41Z")

</div>

Hi,

Are you using FactorySQL or Ignition? If Ignition, are you using the SQL Bridge module? If so, or if FactorySQL, you just need to add the two items to a standard group (or a historical group), and then on the trigger panel select “Async Trigger” or “Only evaluate when values have changed” option (the names are a little different between the two programs).

If you’re using Ignition and want to do it in scripting, I would just create a gateway tag change script that listens to the tags you want, and then use the [tt]system.tag.read()[/tt] and [tt]system.db.runPrepQuery()[/tt] functions. The [documenation](http://inductiveautomation.com/support/usermanuals/ignition/system_tag_read.htm) for read() has an example of using both of them together.

Hope this helps,
