I need to send the result of a procedure to an update statement.
Basically updating the column of one table with the result of a
query in a stored procedure. It only returns one value, if it didnt I
could see why it would not work, but it only returns a count.
Lets say I have a sproc like so:
create proc sp_countclients
@datecreated datetime
as
set nocount on
select count(clientid) as count
from clientstable
where datecreated > @datecreated
Then, I want to update another table with that value:
Declare @dc datetime
set @dc = '2003-09-30'
update anothertable
set ClientCount = (exec sp_countclients @dc) -- this line errors
where id_ = @@identity
OR, I could try this, but still gives me error:
declare @c int
set @c = exec sp_countclients @dc
What should I do?
Thanks in advance!
Greg