Printing ASCII Values

  • Hi Experts,

    I have written a query to print the ASCII values of A to Z.

    Query:

    -------------------------------

    Declare @Start int,@End int

    select @Start =ASCII('A')

    select @End = ASCII('Z')

    while @Start <= @End

    Begin

    select char(@Start),@Start

    select @Start = @Start + 1

    End

    --------------------------------

    Again , i want to avoid 'WHILE LOOP' which leads to RBAR Logic. I want to apply setbased logic to solve the above problem.

    Experts inputs are welcome !

    karthik

  • You are double posting... that'll get you thrown out of the "sandbox"... 😉

    http://www.sqlservercentral.com/Forums/Topic431176-8-1.aspx

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff,

    No..This is a different one.Yes i want to print ascii values of A-Z.

    Can i use the same logic where you replied for my previous question ?

    Kindly tell me, in which situations we go for master.dbo.spt_values table ?

    karthik

  • karthikeyan (12/10/2007)


    Jeff,

    No..This is a different one.Yes i want to print ascii values of A-Z.

    Can i use the same logic where you replied for my previous question ?

    No, it's not different... exact same logic applies.

    Kindly tell me, in which situations we go for master.dbo.spt_values table ?

    I wouldn't... except for simple examples like I did on the other post where I'm sure the person asking doesn't have a Tally table... best thing to do is to use a Tally table, instead. I explain how to make one on the other post.

    If you have any more questions on this, please use the other thread so all the questions and answers about this subject are on a single thread. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply