Add space in data

  • Hi Friends,

    In my table i have column street_number

    what i need is if the street_number <> 0 the i have to add the space after the street_number.

    for this i use the follwing query

    select case when street_number=0 then null else street_number + space(5) end as street_number from mytable where condion

    But its not working?

    can u help me what i did the mistake in the above query?

    Thanks

    Regards

    Tony

  • That's because it looks like you're trying to add spaces to a numeric value which has no effect.  Convert the street number to VARCHAR and then add the spaces to it.

    --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)
    Intro to Tally Tables and Functions

  • Yes.

    I did it for the Float Field.

    Thank you for your suggestion.

     

  • that's a little weird to store an street number in a float. 

    are streets fractional where you live?  if so to how many digits of precision?  

    ---------------------------------------
    elsasoft.org

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

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