Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2015
    Posts
    27

    Post Unanswered: Left Justification

    Hi,

    I have written this query but cant get the output to left justified.
    Its a 10 character length output but its starting 5 spaces beyond the starting point. IS there a way to re-write it
    so it start from the true starting point and I can pad at the end....thanks in advance

    Here's the query:

    REPLICATE(' ',10-LEN(
    ISNULL(
    CASE WHEN LTRIM(REPLACE(A.DIAGN1, '.','')) =''
    THEN NULL
    ELSE LTRIM(REPLACE(A.DIAGN1, '.',''))
    END
    , 'V689')
    ))+ISNULL(
    CASE WHEN LTRIM(REPLACE(A.DIAGN1, '.','')) =''
    THEN NULL
    ELSE LTRIM(REPLACE(A.DIAGN1, '.',''))
    END
    , 'V689') AS PRIME_DIAGN_CODE, --ISNULL(LEFT(' '+REPLACE(A.DIAGN1, '.',''), 10), LEFT(''+'V689'

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    This is a presentation issue and should be handled in whatever your presentation layer is (i.e. report, webpage etc...). Every tool has a job. Use the right one for the right job.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

Tags for this Thread

Posting Permissions

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