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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update column value based on procedure output 1

Status
Not open for further replies.

Mich

IS-IT--Management
Dec 26, 2000
452
US
I have a very long and very complex stored procedure that produces a dollar amount given parameterized values. I have inserted into a temp table all values that will be passed to the procedure. This temp table has one more column that I need to populate with the OUTPUT of the stored procedure. I'm having a hard time getting this to work. Below is a simple example of what I'm trying to do.

Code:
exec proc_AddItUp 1,2,3, @total OUTPUT

The procedure's logic returns @total=6. I have a temp table with fields such as,

Code:
FirstVal     SecondVal     ThirdVal     Total
   1             2            3
   2             3            4
   3             4            5

I need to update the Total column with the output of the procedure using the first three columns as input.

Suggestions??

Thanks in advance.

-If it ain't broke, break it and make it better.
 
Convert the procedure into a user-defined function returning a scalar value, and call it in the following way:
Code:
UPDATE #TempTable
SET Total = dbo.udf_AddItUp(FirstVal, SecondVal, ThirdVal)
 
Perfect example of trying to use a screwdriver instead of a hammer. Thanks for the direction.

-If it ain't broke, break it and make it better.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top