August 4, 2009 at 4:12 am
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
August 4, 2009 at 5:18 am
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
August 4, 2009 at 5:46 am
But this is not a proper solution
August 4, 2009 at 6:16 am
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]
August 6, 2009 at 5:03 am
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
August 6, 2009 at 7:38 am
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