Skip to main content
Inspiring
January 14, 2009
Answered

String or binary data would be truncated. Error

  • January 14, 2009
  • 3 replies
  • 4394 views
Why am I getting this error? All I want to do is set a bit field in my MSSQL DB to either a 0 or a 1. The arguments in my cfc are defined as:

<cfargument name="bitCurrYearID" type="boolean" required="yes">
<cfargument name="bitNextYearID" type="boolean" required="yes">

Error I receive:

Error Executing Database Query.
[Macromedia][SQLServer JDBC Driver][SQLServer]String or binary data would be truncated.

The error occurred in C:\ColdFusion8\wwwroot\TEESO\cfc\ptacfc.cfc: line 384
Called from C:\ColdFusion8\wwwroot\TEESO\pvt\pta\eventadmin\default.cfm: line 23
Called from C:\ColdFusion8\wwwroot\TEESO\cfc\ptacfc.cfc: line 384
Called from C:\ColdFusion8\wwwroot\TEESO\pvt\pta\eventadmin\default.cfm: line 23

382 : <cfstoredproc procedure="prEventsCreateNewYear" datasource="#Application.DB#">
383 : <cfprocparam value="#Arguments.bitCurrYearID#" cfsqltype="CF_SQL_BIT" type="In" null="false">
384 : <cfprocparam value="#Arguments.bitNextYearID#" cfsqltype="CF_SQL_BIT" type="In" null="false">
385 : </cfstoredproc>
386 :

My Calling code is attached:
This topic has been closed for replies.
Correct answer Newsgroup_User
What happens if you run the proc with those arguments via Query Analyser
(or similar)

--
Adam

3 replies

Participating Frequently
January 14, 2009
CF treats Boolean variables as true/false values, whereas you need 1/0 for the database. I typically use a CF numeric datatype as opposed to Boolean so there is no issue. Try changing that and see if it works.
Inspiring
January 14, 2009
I understand that that would be a work around but this should work. I have several of these types of fields and it seems like a bad design to use two bytes per field instead of a single bit.
Participant
January 14, 2009
What does the stored procedure look like?
Inspiring
January 14, 2009
It's a big procedure with multiple steps. However you were on the right track. Thanks!
Newsgroup_UserCorrect answer
Inspiring
January 14, 2009
What happens if you run the proc with those arguments via Query Analyser
(or similar)

--
Adam
Inspiring
January 14, 2009
OK, that was the solution! I ran it from Query Analyzer and discovered that one of the tables' fields had grown by 100 characters. When the field is copied from one table to the other table I of course get this error!