# DELETE SQL with runPrepQuery return error

**URL:** <https://forum.inductiveautomation.com/t/delete-sql-with-runprepquery-return-error/43416>\
**Category:** Ignition\
**Created:** [February 15, 2021, 1:22pm UTC](https://forum.inductiveautomation.com/t/delete-sql-with-runprepquery-return-error/43416 "2021-02-15T13:22:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![etlikmilos](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@etlikmilos](https://forum.inductiveautomation.com/u/etlikmilos)\
**Post date:** [February 15, 2021, 1:22pm UTC](https://forum.inductiveautomation.com/t/delete-sql-with-runprepquery-return-error/43416/1 "2021-02-15T13:22:42Z")

</div>

Hi all  
I have a problem with runPrepQueri when I use this command my SQL command is executed but returns an error.  
What I doing wrong.  
My code :

> id = self.getSibling("Table").props.selection.data[0]['CarovyKod']  
> query = 'DELETE FROM RevizeRucNaradiSpotrebic WHERE CarovyKod = ?'  
> args = [id]  
> system.db.runPrepQuery(query,args)

And the error is here :

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/4/94fdff40e944433e4271abf13a6722668738c28b.png)

---

<div class="post-metadata">

**Author:** ![mcgheeiv](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcgheeiv](https://forum.inductiveautomation.com/u/mcgheeiv)\
**Post date:** [February 15, 2021, 1:38pm UTC](https://forum.inductiveautomation.com/t/delete-sql-with-runprepquery-return-error/43416/2 "2021-02-15T13:38:31Z")

</div>

What happens if you execute the query directly on the database using SSMS (SQL Server) or other database management tool?

The “Details” tab with “Full” selected will provide better clues as well.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [February 15, 2021, 1:59pm UTC](https://forum.inductiveautomation.com/t/delete-sql-with-runprepquery-return-error/43416/3 "2021-02-15T13:59:19Z")

</div>

Since it is a `DELETE FROM` query, I believe you need to user `system.db.runPrepUpdate()` insead.

---

<div class="post-metadata">

**Author:** ![etlikmilos](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@etlikmilos](https://forum.inductiveautomation.com/u/etlikmilos)\
**Post date:** [February 15, 2021, 2:04pm UTC](https://forum.inductiveautomation.com/t/delete-sql-with-runprepquery-return-error/43416/4 "2021-02-15T14:04:06Z")

</div>

Yes, thank you now it working without problems 😃
