Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2006
    Posts
    3

    Unanswered: How to find the ASCII code of a Character

    Hi,
    Is there any method or Built-In function which would help me to find the ASCII code of a Character or of a String(First character) in my SP.
    I would appreciate if some one would give me the solution or point to where the solution can be found.

    Thank's in Advance,
    Ravinandan

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Look in the SQL manual for the function ASCII.

    Andy

  3. #3
    Join Date
    Nov 2004
    Posts
    1,427
    Provided Answers: 4
    Try the
    ASCII()
    function.
    With kind regards . . . . . SQL Server 2000/2005/2012
    Wim

    Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
    Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages

  4. #4
    Join Date
    Jul 2006
    Posts
    3
    Thanks for quick response...

    The ASCII() function worked....but strangely it is not present in the SQL manual.
    The SQL manual from IBM site for DB2 Universal Database for iSeries SQL Reference V5R4(The database i'm using) doesn't have ASCII function in it's Built-In function's list.

    Thanks once again.

  5. #5
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    You can also cast the data as varchar (or char) for bit data.

    SELECT SEX, CAST(SEX AS CHAR FOR BIT DATA) FROM EMPLOYEE FETCH FIRST 1 ROW ONLY

    SEX 2
    --- -----
    F x'46'

    You can also use SUBSTR to isolate a particular character in the string.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

Posting Permissions

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