# Conversion failed from nvarchar to int in a SQL query

**URL:** <https://forum.inductiveautomation.com/t/conversion-failed-from-nvarchar-to-int-in-a-sql-query/28952>\
**Category:** Ignition\
**Created:** [October 9, 2019, 9:27am UTC](https://forum.inductiveautomation.com/t/conversion-failed-from-nvarchar-to-int-in-a-sql-query/28952 "2019-10-09T09:27:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmcallister](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@bmcallister](https://forum.inductiveautomation.com/u/bmcallister)\
**Post date:** [October 9, 2019, 9:27am UTC](https://forum.inductiveautomation.com/t/conversion-failed-from-nvarchar-to-int-in-a-sql-query/28952/1 "2019-10-09T09:27:01Z")

</div>

I am trying to run a SQL query to delete an item from a database. I have created a memory tag as type Integer. When I run the query I get an error that it failed to convert nvarchar to int. The memory tag is int and the column in the database is int. What am I doing wrong?

Script looks like this:

boxnum = “BoxNumForRemoval”

If boxnum is not None:  
confirm = system.gui.confirm(“Are you sure to remove box %s ?” % boxnum, “Remove Box”)  
if confirm:  
server = “SQLServer\_New”  
txID = system.db.beginTransaction(server)

```
      query = "DELETE FROM BoxLabelData WHERE BoxNumber >= ?"
      args = [boxnum]
      system.db.runPrepUpdate (query, args, server, tx = txID)

      system.db.commitTransaction(txID)
      system.db.closeTransaction(txID)
 else:
      system.gui.messageBox("No Box Selected", "Invalid Selection")
```

---

<div class="post-metadata">

**Author:** ![bmcallister](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@bmcallister](https://forum.inductiveautomation.com/u/bmcallister)\
**Post date:** [October 9, 2019, 10:00am UTC](https://forum.inductiveautomation.com/t/conversion-failed-from-nvarchar-to-int-in-a-sql-query/28952/2 "2019-10-09T10:00:36Z")

</div>

Never mind. I figured it out. It’s tough being in china with no internet connection to be able to use the help.

---

<div class="post-metadata">

**Author:** ![chasondeshotel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chasondeshotel/32/20032_2.png) [@chasondeshotel](https://forum.inductiveautomation.com/u/chasondeshotel)\
**Post date:** [October 9, 2019, 4:29pm UTC](https://forum.inductiveautomation.com/t/conversion-failed-from-nvarchar-to-int-in-a-sql-query/28952/3 "2019-10-09T16:29:29Z")

</div>

What was the solution?

---

<div class="post-metadata">

**Author:** ![bmcallister](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@bmcallister](https://forum.inductiveautomation.com/u/bmcallister)\
**Post date:** [October 14, 2019, 4:53pm UTC](https://forum.inductiveautomation.com/t/conversion-failed-from-nvarchar-to-int-in-a-sql-query/28952/4 "2019-10-14T16:53:39Z")

</div>

I got rid of the tags and bound directly to the properties of the number field.
