Cast from CHAR(20) to SMALLINT

General
Enthusiast

Cast from CHAR(20) to SMALLINT

Hello Friends.

I am trying to convert a column havign CHAR(20) to SMALLINT and getting the below error....

I have the below distinct values....as char(20).

this query Cast(cast(red_Cd as CHAR(3)) AS SMALLINT) and getting this error.

Bad character in date or format..you help is appreciated..thanks...

?

-1

100

101

102

104

106

110

111

112

119

204

205

211

300

302

303

304

306

307

309

310

311

313

315

316

500




Thanks...

Tags (1)
1 REPLY
Enthusiast

Re: Cast from CHAR(20) to SMALLINT

I just created the same scenario on my databases (13 & 14) and it worked fine w/o any error, unless '?' is actually 'question mark' and not representing the NULL value.

Are you sure, it is throwing the error at this particular statement ?