Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Execute Stored Procedure in UPDATE statement

Status
Not open for further replies.

rduncan10

IS-IT--Management
Jun 15, 2004
4
US
I'm new to SQL Server and I am having some trouble with something that seems to me should be quite easy. I want to update a field to the return value of stored procedure.

So the code looks sort of like this

UPDATE table1
SET totHours = EXECUTE sp_calcHours @hours OUTPUT
WHERE otHours > 16

That's a bit simplified (there should be input parameters too, but you get the idea I hope. The calculations in sp_calcHours are quite complex.

I'm working in an Access ADP file and it tells me "Incorrect Syntax Near EXECUTE".

Can this be done? The only other way around it I can see is to use a DECLARE LOCAL CURSOR loop to go through the entire table to do the calculation, but it seems to me it should be easier than that.

Thanks,
Rob
 
Bad idea, do not mention using a cursor for this.

Put the calculation inthe update statement.


Questions about posting. See faq183-874
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top