Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2005
    Posts
    4

    Unanswered: Combine select and exec with union all

    I basically want to combine a select and an exec of a stored procedure with a union all.

    Is this possible?
    Each result of course has the same fields.

    A sample of my code is below:


    exec attendance..up_prepaidvac

    UNION ALL
    select
    badge,
    dept,
    leave_type,
    code2,
    hours = sum(hours),
    rate = round(cast(rate AS decimal(7, 2)), 2),
    dollars = round(cast(SUM(dollars) AS decimal(8, 2)), 2),
    not_ot = sum(not_ot),
    ot_hours = sum(ot_hours)
    from vw_timetopay
    where 1=1
    and leave_type <> '80' --exclude pre-paid vaca
    group by badge, dept, leave_type, code2, rate
    having SUM(hours) > 0

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Not directly. You would have to insert the results of the stored procedure in a temp table, then union the temp table with the other select.

  3. #3
    Join Date
    Apr 2005
    Posts
    4
    thats what I was thinking. Thanks for the input

Posting Permissions

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