471,092 Members | 1,547 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,092 software developers and data experts.

Set variable based on result of procedure OR update columns fromsproc result

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

Jul 20 '05 #1
0 1482

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Stanley Sinclair | last post: by
1 post views Thread by Don Leverton | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.