# Inserting a tag value into a scripted SQL query

**URL:** <https://forum.inductiveautomation.com/t/inserting-a-tag-value-into-a-scripted-sql-query/23796>\
**Category:** Ignition\
**Created:** [April 2, 2019, 6:45pm UTC](https://forum.inductiveautomation.com/t/inserting-a-tag-value-into-a-scripted-sql-query/23796 "2019-04-02T18:45:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ethanrendlen](https://avatars.discourse-cdn.com/v4/letter/e/77aa72/32.png) [@ethanrendlen](https://forum.inductiveautomation.com/u/ethanrendlen)\
**Post date:** [April 2, 2019, 6:45pm UTC](https://forum.inductiveautomation.com/t/inserting-a-tag-value-into-a-scripted-sql-query/23796/1 "2019-04-02T18:45:41Z")

</div>

Hello,  
I am trying to add a tag value into a scripted SQL query that will work if I use a test string, SO IM CLOSE! Help me out here it is almost done.

```
jobnum = system.tag.read("{[PanelShop]JobNumSelect}").value
 
query = "INSERT INTO Notes (note, whoid, tstamp, attachment, filename, sticky, JobNum) VALUES (?, ?, CURRENT_TIMESTAMP, CONVERT(VARBINARY(MAX),?), ?, ?, ?)"
 
arguments = [note, user, attachmentBytes, filename, sticky, jobnum]
system.db.runPrepUpdate(query, arguments)

```

If I replace the “system.tag.read(”{[PanelShop]JobNumSelect}").value" with ‘test’ it works. So I am not reading into the variable the tag value correctly. I have tried this:

arguments = [note, user, attachmentBytes, filename, sticky, str(jobnum)]

type of thing to make sure its a string that gets passed but that does not seem to be the issue.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 2, 2019, 6:50pm UTC](https://forum.inductiveautomation.com/t/inserting-a-tag-value-into-a-scripted-sql-query/23796/2 "2019-04-02T18:50:43Z")

</div>

Try it without the braces. They’re not used in scripting. 😉

```auto
jobnum = system.tag.read("[PanelShop]JobNumSelect").value

```

---

<div class="post-metadata">

**Author:** ![ethanrendlen](https://avatars.discourse-cdn.com/v4/letter/e/77aa72/32.png) [@ethanrendlen](https://forum.inductiveautomation.com/u/ethanrendlen)\
**Post date:** [April 2, 2019, 6:52pm UTC](https://forum.inductiveautomation.com/t/inserting-a-tag-value-into-a-scripted-sql-query/23796/3 "2019-04-02T18:52:57Z")

</div>

wow, thanks for that, easy fix. FIXED
