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

String or binary data would be truncated. Error

Explorer ,
Jan 14, 2009 Jan 14, 2009

Copy link to clipboard

Copied

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

Views

4.1K

Translate

Translate

Report

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

Votes

Translate

Translate
LEGEND ,
Jan 14, 2009 Jan 14, 2009

Copy link to clipboard

Copied

What happens if you run the proc with those arguments via Query Analyser
(or similar)

--
Adam

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

What does the stored procedure look like?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST
It's a big procedure with multiple steps. However you were on the right track. Thanks!

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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
Documentation