Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

String or binary data would be truncated. Error

Explorer ,
Jan 14, 2009 Jan 14, 2009
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:
TOPICS
Advanced techniques
4.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 14, 2009 Jan 14, 2009
What happens if you run the proc with those arguments via Query Analyser
(or similar)

--
Adam
Translate
LEGEND ,
Jan 14, 2009 Jan 14, 2009
What happens if you run the proc with those arguments via Query Analyser
(or similar)

--
Adam
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 14, 2009 Jan 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!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 14, 2009 Jan 14, 2009
What does the stored procedure look like?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 14, 2009 Jan 14, 2009
LATEST
It's a big procedure with multiple steps. However you were on the right track. Thanks!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 14, 2009 Jan 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 14, 2009 Jan 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources