Results 1 to 2 of 2

Thread: ASCII Code Table in SQL

  1. #1
    Join Date
    Mar 2008
    Posts
    116

    ASCII Code Table in SQL

    The following procedure gets the Ascii Conversion Table and displays all the ASCII code starting from 0 to 255. The procedure takes an int type argument and will show the ASCII code starting from that particular number.

    Let's assume if we want to display the ASCII table starting from 100 till 255, then we will call the procedure using

    exec convASCII 100


    CREATE PROCEDURE convASCII

    @counter int -- Argument describing the starting number for the table

    AS

    DECLARE @col int, @strline varchar(3000) -- strline is going to store the ASCII code table

    SET @col = 0

    SET @strline = ' '

    -- Let's make a loop starting from the counter variable till 255.

    WHILE @counter <= 255

    begin

    We are making the table to display 10 ASCII codes in a row i.e. 10 columns in one row.

    WHILE @col < 10

    BEGIN

    SET @strline = @strline + ' | ' + convert(varchar(4), @counter)+ ' - ' + CHAR(@counter) -- Displaying the ASCII code and the character code in the table. CHAR converts the int ASCII code to character. CONVERT function converts the second argument type to the data type provided in the first argument.

    SET @counter=@counter+1 - increment the counter
    SET @col = @col + 1 - increment the column
    END
    SET @strline = CHAR(9) + @strline + ' | ' + CHAR(13) -- Char(9) is the TAB key and CHAR(13) is for Carriage Return

    SET @col = 0
    end
    PRINT @strLine -- Display the ASCII Codes.

  2. #2
    Join Date
    May 2008
    Posts
    39

    Re: ASCII Code Table in SQL

    ASCII reserves the first 32 codes (numbers 0–31 decimal) for control characters: codes originally intended not to carry printable information, but rather to control devices (such as printers) that make use of ASCII, or to provide meta-information about data streams such as those stored on magnetic tape. For example, character 10 represents the "line feed" function (which causes a printer to advance its paper), and character 8 represents "backspace". Control characters that do not include carriage return, line feed or white space are called non-whitespace control characters.

Similar Threads

  1. Link a Table to another Table to Drop Down In Main Table
    By himeshRES in forum Windows Software
    Replies: 6
    Last Post: 11-12-2010, 02:01 PM
  2. Html program code for table
    By Sonam Goenka in forum Software Development
    Replies: 6
    Last Post: 29-12-2009, 08:03 AM
  3. Full Ascii table for reference
    By MindSpace in forum Software Development
    Replies: 3
    Last Post: 12-01-2009, 10:56 AM
  4. How to use the ASCII code on SONY VAIO Laptop
    By NavinS in forum Portable Devices
    Replies: 3
    Last Post: 23-12-2008, 02:53 PM
  5. C++ program to display ASCII code of a word or phrase
    By Sonic in forum Software Development
    Replies: 2
    Last Post: 12-11-2008, 01:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,144,344.18180 seconds with 16 queries