Show result in single table

  • I have a procedure that take one paramete as int and show name

    my problem is that i want to use that procedure multiple time and output will have in single table.

    like

    procedure is

    create proc chekck

    (

    @category int

    )

    as

    begin

    select category_name from category where id=@category

    end

    use this

    with show as

    (

    chekck 1

    union all

    chekck 1

    )

    select * from show

    this give me error

    Plz help me

  • Hi,

    only possible like this

    insert into show

    exec chekck 1

    insert into show

    exec chekck 2

    insert into show

    exec chekck 3

    select * from show

  • But this is not a proper solution

  • satishbhargav4u (8/4/2009)


    But this is not a proper solution

    Hi satishbhargav4u,

    It is certainly a solution, as in it will work in place of the code that gives you an error. I think we will need more info regarding your problem. I have a couple of questions to start with; are you stuck with that SP or can it be changed? Is the CTE that gives you the error hard coded or are you generating it based on the required ID's? How many seperate ID's are likely to be requested at once to appear in this single result set?

    cheers,

    Rob

    --------
    [font="Tahoma"]I love deadlines. I like the whooshing sound they make as they fly by. -Douglas Adams[/font]

  • with t as

    (

    select 'hello' as h

    union all

    select 'bye' as h

    )

    select * from t

    This work fine but

    when i write

    with t as

    (

    check 1

    union all

    check 2

    )

    where check is procedure

    It not work properly. It give some error

    Please not give me the solution olny tell me that what i wrote wrong and reason of error

    select * from t

  • satishbhargav4u (8/6/2009)

    Please not give me the solution olny tell me that what i wrote wrong and reason of error

    Fair enough! The code you wrote was wrong, the reason you received an error is the UNION operator is for use with SELECT queries.

    --------
    [font="Tahoma"]I love deadlines. I like the whooshing sound they make as they fly by. -Douglas Adams[/font]

Viewing 6 posts - 1 through 5 (of 5 total)

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