# The data types text and varchar are incompatible in the equal to operator

**URL:** <https://forum.inductiveautomation.com/t/the-data-types-text-and-varchar-are-incompatible-in-the-equal-to-operator/68624>\
**Category:** Ignition\
**Created:** [January 16, 2023, 12:46pm UTC](https://forum.inductiveautomation.com/t/the-data-types-text-and-varchar-are-incompatible-in-the-equal-to-operator/68624 "2023-01-16T12:46:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lei\_Qu](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@Lei\_Qu](https://forum.inductiveautomation.com/u/Lei_Qu)\
**Post date:** [January 16, 2023, 12:46pm UTC](https://forum.inductiveautomation.com/t/the-data-types-text-and-varchar-are-incompatible-in-the-equal-to-operator/68624/1 "2023-01-16T12:46:29Z")

</div>

Hi Ignition professionals,

I run the simple query as showing in the photo but I get the showing error all the time. Can you please advise to resolve this? Thanks.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/0/8022156d8303454656d0a4b32a7b14e4364f3bd5.png)

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 16, 2023, 12:53pm UTC](https://forum.inductiveautomation.com/t/the-data-types-text-and-varchar-are-incompatible-in-the-equal-to-operator/68624/2 "2023-01-16T12:53:47Z")

</div>

You'll need to either cast or convert the `Text` column to varchar in the query.

```auto
UPDATE Ford_Raptor
SET Passenger_Rivnut_1_Torque = 12.0
WHERE CONVERT(varchar, Part_Number) = '123'

```

---

<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:** [January 16, 2023, 1:44pm UTC](https://forum.inductiveautomation.com/t/the-data-types-text-and-varchar-are-incompatible-in-the-equal-to-operator/68624/3 "2023-01-16T13:44:08Z")

</div>

Or convert the database column to varchar instead of text.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [January 16, 2023, 1:51pm UTC](https://forum.inductiveautomation.com/t/the-data-types-text-and-varchar-are-incompatible-in-the-equal-to-operator/68624/4 "2023-01-16T13:51:26Z")

</div>

I'd recommend this way as you can't index a text column outside a FULLTEXT index. VARCHAR's behave more like other datatypes in this regard. Seeing as the column is `Part_Number`, I don't think you need to allow for 65k characters.

---

<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:** [January 16, 2023, 2:07pm UTC](https://forum.inductiveautomation.com/t/the-data-types-text-and-varchar-are-incompatible-in-the-equal-to-operator/68624/5 "2023-01-16T14:07:38Z")

</div>

@dkhayes117 has the right answer, but in the future, if there's a type mismatch between a column value and a supplied parameter, cast the **parameter** to the column's type, not vice versa. That way it will only be executed once when setting up the query, not for every row.

---

<div class="post-metadata">

**Author:** ![Lei\_Qu](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@Lei\_Qu](https://forum.inductiveautomation.com/u/Lei_Qu)\
**Post date:** [January 16, 2023, 4:10pm UTC](https://forum.inductiveautomation.com/t/the-data-types-text-and-varchar-are-incompatible-in-the-equal-to-operator/68624/6 "2023-01-16T16:10:31Z")

</div>

Thanks, everyone. It was great.
