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

Stored Proc to update one table with data from another table

Status
Not open for further replies.

WaveOut

Programmer
Sep 6, 2002
42
US
My tables:

CRAFT TABLE
id
weeklyuid
craftname
wage

WAGERATE TABLE
id
craftid
plantid
wagerate

I have two tables craft and wagerates. I want to sort the craft table on the weeklyUID field and update all records that meet the sort criteria with a wage rate that is looked up in the wagerate table.

I'm trying to get the following stored procedure to work but I'm not having any luck:

Code:
CREATE PROCEDURE spUpdateWages
        @wuid uniqueidentifier,
        @plantid integer,
        @craftid integer
AS
BEGIN

Update Craft2
set
craft2.wage = (select wagerate from wagerates where plantid = @plantid and craftid = @craftid)
where weeklyuid = @wuid
END
GO

How do you access two diffrent tables from a single stored procedure?

Dave

 
What doesn't work, do you get an error? Can you show some sample data and how you want it to look after the update?

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top