Is it possible to format and style this code?

  • Hello experts,

    This is probably not possible but I thought I would ask anyway.

    This query below:

    SELECT c.charity_name,dbo.formatCurrency(em.[check_amt],2,1) CheckTotal, dbo.formatCurrency(em.cash,2,1) CashTotal, e.[e_mail]

    FROM charity_table c,[emp_e_mail] e,active_empl a,

    employee_ded_amts em

    WHERE(c.charity_code = em.charity_code)

    AND a.employee_id = e.employee_id

    AND e.employee_id = em.employee_id

    AND em.employee_id = '00443320'

    AND (isnull(em.check_amt, 0)<> 0

    OR isnull(em.cash, 0)<> 0)

    UNION ALL

    SELECT 'Total',dbo.formatCurrency(SUM(IsNull(em.[check_amt],0)),2,1),dbo.formatCurrency(SUM(IsNull(em.cash,0)),2,1), e.[e_mail]

    FROM charity_table c,[emp_e_mail] e,active_empl a,

    employee_ded_amts em

    WHERE(c.charity_code = em.charity_code)

    AND a.employee_id = e.employee_id

    AND e.employee_id = em.employee_id

    AND em.employee_id = '00443320'

    AND (isnull(em.check_amt, 0)<> 0

    OR isnull(em.cash, 0)<> 0)

    Group by e.[e_mail]

    Returns results similar to this:

    Name Check Cash Email

    Name1$13.00$0.00email1

    Name2$15.00$0.00email2

    Name3$0.00$21.00email3

    Total$28.00$21.00

    Is it at all possible to format the result in such that a horizontal line is placed just before the name Total so it looks more like this:

    Name Check Cash Email

    Name1$13.00$0.00email1

    Name2$15.00$0.00email2

    Name3$0.00$21.00email3

    ________________________________

    Total$28.00$21.00

    This is a more preferred result presentation but again,not sure if it is possible.

    The code works fine. It is just the presentation.

    Thanks alot

  • I assume you are using SSMS for this?

    SSMS is not designed as a presentation layer so doing something like this is not really possible.

    Use a front-end report system such as SSRS which would be perfect for these requirements

  • TSQL is a querying language, not a presentation and formatting language. If you want to change the format, you need to have a report, a spreadsheet, or build an application.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

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

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