right aligned data

  • hi,

    my query is:

    SELECT CAST(OID AS varchar(15)) ...........................

    this is a possible result:

    123456789012345

    345____________

    45_____________

    4435666565656__

    but I want right aligned data:

    123456789012345

    ____________345

    _____________45

    __4435666565656

    it's possible with a query ?

    Thanks, anakin

  • You can't do it easily. Something like this will give the desired result.

    
    
    SELECT SPACE(15 - len(cast(OID AS varchar(15)))) + cast(OID as varchar(15))
  • Hi,

    Where do you want right aligned data - on a report, on screen? The above approach will only work if you are using a proportional font.

    Regards,

    Andy Jones

    .

  • no, I don't show data, the problem arise because I must order data by a calcutated text field.

    My calculated text field si the concatenation of two fields, the second field is allways my numerical OID field, the first field is a variable datatype field.

    When the first field is of type string it's ok, but is of type int I must include some blank otherwise the order is wrong.

  • Try

    STR(OID,15,0)

    Far away is close at hand in the images of elsewhere.
    Anon.

  • I second for Davids suggestion. Of the most used options it is the easiest to read, and least code to write.

Viewing 6 posts - 1 through 5 (of 5 total)

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