Query output to txt file & columnheader headers

  • Hi,

    I hope anyone can help me with this annoying problem.

    Some queries I have scheduled in job have a text file as output file. All works, but often the columnheaders of the result are underlined with "-" which is far to wide. Example 'servername' as header, but 128 x "-" as underline.

    Can I change this so it gets trimmed ?

    thx2all

  • You are getting 128 dashes because that column has been declared as having a lenght of 128.

    I can only suggest using [font="Courier New"]SUBSTRING(long_column, 1, 30) AS long_column[/font].

    I cannot test it in the Query Analyzer because, way back when, I had set an option to not output the dash line between the column names and the first line of results in the results pane. I just do not remember how I did it.

  • Hey J, thanks for the reply anyway. If you can disable the dashes, I can do some more searches on this.

    Grtz,

    T.

  • Mind you, I was talking about the Query Analyzer only.

    "Are you Sarah Connor?"

  • owkee.

    I need you clothes and motorcycle... 😀

  • T2000 (2/13/2009)


    Hey J, thanks for the reply anyway. If you can disable the dashes, I can do some more searches on this.

    Grtz,

    T.

    Cast the output as VARCHAR(DesiredColumnWidthHere).

    --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

  • thank you for your input Jeff! Will try this.

    rgds,

    T.

  • You bet... thanks for the feedback. Let us know how it works out for you.

    --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

  • Cast the output as CONVERT(VARCHAR(DesiredColumnWidthHere), long_column_name) AS long_column_name.

    Interesting.

    So I suppose this is more efficient than SUBSTRING ?

    Regards

  • J (2/16/2009)


    Cast the output as CONVERT(VARCHAR(DesiredColumnWidthHere), long_column_name) AS long_column_name.

    Interesting.

    So I suppose this is more efficient than SUBSTRING ?

    Regards

    Sorry to use the ol' cliche`, but it depends... sometimes SUBSTRING won't change the length of the output column. Casting the final result of the column always does.

    --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

Viewing 10 posts - 1 through 9 (of 9 total)

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