# Sql escape

**URL:** <https://forum.inductiveautomation.com/t/sql-escape/2342>\
**Category:** Archived Topics\
**Created:** [November 15, 2010, 2:21pm UTC](https://forum.inductiveautomation.com/t/sql-escape/2342 "2010-11-15T14:21:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![trsimmons](https://avatars.discourse-cdn.com/v4/letter/t/2acd7d/32.png) [@trsimmons](https://forum.inductiveautomation.com/u/trsimmons)\
**Post date:** [November 15, 2010, 2:21pm UTC](https://forum.inductiveautomation.com/t/sql-escape/2342/1 "2010-11-15T14:21:01Z")

</div>

I have a table bound to an sql query and when a result returns that contains a field with a single quote, the query fails. How do I implement the sql escape character function?

thanks  
travis

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [November 16, 2010, 4:51pm UTC](https://forum.inductiveautomation.com/t/sql-escape/2342/2 "2010-11-16T16:51:32Z")

</div>

What property is your query on? What is the error you are getting? An SQL query returning a single quote should not cause an error if it is going to a string or dataset property.

---

<div class="post-metadata">

**Author:** ![trsimmons](https://avatars.discourse-cdn.com/v4/letter/t/2acd7d/32.png) [@trsimmons](https://forum.inductiveautomation.com/u/trsimmons)\
**Post date:** [November 16, 2010, 5:03pm UTC](https://forum.inductiveautomation.com/t/sql-escape/2342/3 "2010-11-16T17:03:19Z")

</div>

I have a table component that i am populating with a dataset from an mssql db.  
SELECT RecipeName as “Recipe”, Brand, RecipeCode as “Item Code” FROM FSQLDB

When a single quote was returned in the Brand field (ie Todd’s), it stopped working. Changed the table to reflect Todds in the field and it worked fine.

thanks  
t.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [November 16, 2010, 7:35pm UTC](https://forum.inductiveautomation.com/t/sql-escape/2342/4 "2010-11-16T19:35:35Z")

</div>

That is bizarre. What version of FactoryPMI are you running?

---

<div class="post-metadata">

**Author:** ![trsimmons](https://avatars.discourse-cdn.com/v4/letter/t/2acd7d/32.png) [@trsimmons](https://forum.inductiveautomation.com/u/trsimmons)\
**Post date:** [November 16, 2010, 7:39pm UTC](https://forum.inductiveautomation.com/t/sql-escape/2342/5 "2010-11-16T19:39:29Z")

</div>

1.8.3----

on a side note - how do i specify datasource.table.field properly in a SQL query to bind to table component? I have multiple datasource i need to bring together for a table.

thanks  
t.

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [November 16, 2010, 8:04pm UTC](https://forum.inductiveautomation.com/t/sql-escape/2342/6 "2010-11-16T20:04:31Z")

</div>

To pull a single value out of the table, you can create a dynamic property and set an Expression binding to something like this:`if(len({Root Container.Table.data})>0,
    {Root Container.Table.data}[{Root Container.Table.selectedRow},"ColumnName"],
    0)`That will give you the Column you want from the row that is currently selected, and if nothing is selected, then it will return 0.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [November 17, 2010, 6:30pm UTC](https://forum.inductiveautomation.com/t/sql-escape/2342/7 "2010-11-17T18:30:32Z")

</div>

As far as the bug you reported at the top of this thread, I would recommend upgrading, as version 1.8.3 is quite out-of-date.

---

<div class="post-metadata">

**Author:** ![trsimmons](https://avatars.discourse-cdn.com/v4/letter/t/2acd7d/32.png) [@trsimmons](https://forum.inductiveautomation.com/u/trsimmons)\
**Post date:** [November 17, 2010, 6:34pm UTC](https://forum.inductiveautomation.com/t/sql-escape/2342/8 "2010-11-17T18:34:46Z")

</div>

I talked to Vannessa last week about an upgrade - we will probably try to work it in middle of next month.

thanks  
t.
