# SQL - Error: (String Data, Right Truncation, Invalid Character value for cast specifications (01004))

**URL:** <https://clarionhub.com/t/sql-error-string-data-right-truncation-invalid-character-value-for-cast-specifications-01004/3894>\
**Category:** questions\
**Tags:** mssql, odbc\
**Created:** [February 25, 2021, 7:23pm UTC](https://clarionhub.com/t/sql-error-string-data-right-truncation-invalid-character-value-for-cast-specifications-01004/3894 "2021-02-25T19:23:48Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![vitesse](https://clarionhub.com/user_avatar/clarionhub.com/vitesse/32/837_2.png) [@vitesse](https://clarionhub.com/u/vitesse)\
**Post date:** [August 31, 2022, 4:18am UTC](https://clarionhub.com/t/sql-error-string-data-right-truncation-invalid-character-value-for-cast-specifications-01004/3894/12 "2022-08-31T04:18:06Z")

</div>

> [@anon23294430](#):
>
> I think unique keys defined in the dct using cstrings over 1000 characters throw this message or similar if using a tps file as well.

you might be right but TBH I wouldn’t use a CSTRING in a key (because I would be nervous about crud after the terminating null), and if I ever did I certainly wouldn’t have a key over 1000 characters.

The error you are referring to could be due to storing the position in a variable which is too small? This one:

> [@What causes an Error 78 and/or sometimes "phantom" records in a browse?](https://clarionhub.com/t/what-causes-an-error-78-and-or-sometimes-phantom-records-in-a-browse/999):
>
> Here is a reproduction of my old PTSS report. @Mark_Sarson might be able to describe the situation he found today with phantom records due to the same issue? Clarion 8 PTSS - [Problem-Tracker Support System](http://problemtracker.softvelocity.com/clarion8/UpdtCustBugsview.php?ID1=39361) Clarion 9 PTSS - [Problem-Tracker Support System](http://problemtracker.softvelocity.com/clarion9/UpdtCustBugsview.php?ID1=39361) Problem Reference: 39361 Date Received: 2012-05-30 Status: Opened for Review Fixed in Build Number: Product: Clarion8 Build No: 89285 Operating System: Category ID: ABC Classes Summary: Variables used with return value from Position(…

---

_[View the full topic](https://clarionhub.com/t/sql-error-string-data-right-truncation-invalid-character-value-for-cast-specifications-01004/3894)._
