# SQL Query from Script - Can This be Done

**URL:** <https://forum.inductiveautomation.com/t/sql-query-from-script-can-this-be-done/24240>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [April 18, 2019, 7:34pm UTC](https://forum.inductiveautomation.com/t/sql-query-from-script-can-this-be-done/24240 "2019-04-18T19:34:31Z")\
**Posts on this page:** 2\
**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 18, 2019, 7:34pm UTC](https://forum.inductiveautomation.com/t/sql-query-from-script-can-this-be-done/24240/1 "2019-04-18T19:34:31Z")

</div>

Hello,

I am trying to pass variables into the query, this was working without making the column name a variable, but now I am trying to write a general case where it will use the custom value of each page to identify which column it should UPDATE.

queryValue = system.tag.read(’[PanelShop]JobNumSelect’).value

system.db.runPrepUpdate(""“UPDATE PanelShop.dbo.ActiveList SET %s = (?) WHERE JobNum = (?)”"" % str(event.source.Area) , [0, str(queryValue)])  
##################################################################  
This returns no error

I have also tried this:  
runPrepUpdate(“UPDATE DATABASE SET (?) = (?) WHERE COLUMN1 = (?)” , [Argument1, arg2, arg3])

##################################################################

The query works if I just do:  
(“UPDATE DATABASE SET COLUMN2 = (?) WHERE COLUMN1 = (?)” , [Argument1, arg2])

Help there is no error code

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 18, 2019, 7:38pm UTC](https://forum.inductiveautomation.com/t/sql-query-from-script-can-this-be-done/24240/2 "2019-04-18T19:38:57Z")

</div>

Column names and table names are part of the structure of a query, and cannot be substituted with ? placeholders. Those can only provide _ **data** _ to the query, not structure. You’ll need to use string interpolation for the column name. Note that the parentheses around your placeholders are not necessary.
