cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Reports - case varchar changed to a 'string' datatype and truncated to 32

Former Member
0 Kudos

Hi, I am using Crystal Reports version 11.0.0.1282

I am using the 'Command' option in the database expert section. I have a case statement with multiple when clauses: when fielda 'xxxx' then 'xxxxxxxxxxx' , when fielda 'yyyyy' then 'yyyyyyyyyyy', etc. I end the case statement with End as 'Description'. 'fielda' is a varchar 255 field (usuall never gets anywhere near 255), but the command is defaulting the 'Description' to a String [32] datatype. So my display description of 50 characters gets truncated to 32 characters. I have done many searches and I see that there are truncation issues with CR but I couldn't find my exact issue. I did find one that said to use 'Cast' so I tried that but it didn't work. This is what I tried:

When fielda like '%xxxx%' then CAST('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' as VARCHAR(50)).

Any help with this issue would be deeply appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

DellSC
Active Contributor
0 Kudos

What type of database are you connecting to? What type of a connection are you using (ODBC, OleDB, Native, etc.)? What version of Crystal are you using (please go to Help>>About and get the exact version number!)

Also, you might want to try putting the "Cast()" around the case statement as a whole instead of around the individual parts - so it would look something like this:

CAST(
case
...
end as VARCHAR(50)) as Description

-Dell

Answers (3)

Answers (3)

DellSC
Active Contributor
0 Kudos

Please mark my response as the "Best Answer" so that others will know what the solution is and so that the question is closed.

Thanks!

-Dell

Former Member
0 Kudos

That worked! you are a life saver 🙂

Former Member
0 Kudos

Thanks for responding Dell, I will try that. I am using ODBC to a cache db.