Query results formatting

  • Hi,

    Can someone please tell me how to remove ------------ lines from output while sending query results via mail using xp_sendmail?

    I need to send few columns in output from a simple select query to end user via mail.

    Please help.

    TIA,

    MJ

  • If this is a recurring requirement, how about creating a report in Reporting Services, and then creating a subscription to it? If it's a one-time event, I'd say take the query output in grid mode within SSMS and then copy and paste the grid into Excel and format to your heart's content.

    Steve

    (aka smunson)

    :):):)

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • There's a really, really simple way to get simple returns from a query to look great... lookup sp_MakeWebTask. With a little effort, you can also turn out some absolutely astounding looking reports, without reporting services, by using and tuning templates. Like I said, lookup sp_MakeWebTask in Books Online.

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

  • Also, take a look at FOR XML PATH and formatting query results into an HTML table. I have several scheduled jobs set up that use this method of extracting and displaying data.

    I started looking for alternative methods of displaying query results when trying to attach data as a query using database mail and encountering large amounts of blank space which appeared to be the result of "padding" where the data length was less than the field length.

    🙂

  • Hey Jeff,

    I was looking for the SP_MakeWebTask but the following appears on my screen.

    sp_makewebtask is retained for backward compatibility. New Web pages are more easily created using Microsoft SQL Server 2005 Reporting Services (SSRS).

    To execute sp_makewebtask you must be a member of the sysadmin fixed server role.

    This feature will be removed in the next version of Microsoft SQL Server. Do not use this feature in new development work, and modify applications that currently use this feature as soon as possible.

    wkr,

    Eddy

  • eddy (11/17/2008)


    Hey Jeff,

    I was looking for the SP_MakeWebTask but the following appears on my screen.

    sp_makewebtask is retained for backward compatibility. New Web pages are more easily created using Microsoft SQL Server 2005 Reporting Services (SSRS).

    To execute sp_makewebtask you must be a member of the sysadmin fixed server role.

    This feature will be removed in the next version of Microsoft SQL Server. Do not use this feature in new development work, and modify applications that currently use this feature as soon as possible.

    wkr,

    Eddy

    Then, I guess you may be stuck with SSRS to do this. You could suppress all header info with a call to OSQL, but that would also require a call to xp_CmdShell.

    --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 6 posts - 1 through 5 (of 5 total)

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