Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2002
    Posts
    4

    Lightbulb Unanswered: Newbie: Cast VARCHAR to SMALLINT

    Hi all

    To cast a VARCHAR to a SMALLINT isn't really hard to achieve... But I have some fields where only a " " (blank) is in it. So UDB is returning the error message:

    Invalid character found in a character string argument of the function "SMALLINT"

    Does anyone have a solution to this?

    Thank you very much!

    With best regards
    Frederik

  2. #2
    Join Date
    Feb 2002
    Posts
    96

    Thumbs up Re: Newbie: Cast VARCHAR to SMALLINT

    Try this.

    select cast((case when col_name=' ' then '0' else col_name end) as smallint) from table_name;

    Regards.

  3. #3
    Join Date
    Nov 2002
    Posts
    4

    It worked!

    Thank you very much! It works and I am so happy ;-)!

    With best regards
    Frederik

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •