Click to See Complete Forum and Search --> : Insert Into...in Store Prcedure with variable


vplag
February 24th, 2006, 04:03 AM
hello

i have this store procedure...

CREATE PROCEDURE [dbo].[RC] AS
select count(*) as Resulte from calls_pool
GO

it returns me the recordcount of the table calls pool.

also i have this procedure...

CREATE PROCEDURE [dbo].[inserta] AS

declare @return bigint
exec @return=RC

insert into oop (aaa) values (@return)
GO

into the procedure inserta, i want to load to the variable @return the recordcount (like function). then i want to insert this value to the table oop... but into the table stores me the value 0... if i replace the setence :
"insert into oop (aaa) values (@return)"

with the setence

"PRINT 'The sp returned: ' + convert(char(2),@return)" it work normal!

why is happend????

Thanks

Shuja Ali
February 24th, 2006, 08:26 AM
Change your first procedure so that it is able to return value once it checks the count

CREATE PROCEDURE [dbo].[RC] AS
return (select count(*) as Resulte from calls_pool)
GO
That should solve your problem.

vplag
February 24th, 2006, 08:34 AM
it works!

i know for the return value but i think it's very stupit to return the value twice....
it was the only thing that i don't try for the upper reason....

Thanks a lot Shuja!