Update Stored Procedure - Help needed
Hi All
Can someone clever please help me with my update Stored procedure - it will be hugely appriciated.
I have 3 tables:
tblContainer
ContNum (PK) smallint
Length smallint
StopDistance smallint
ContTypeID tinyint
HaulID tinyint
tblContTypes
ContTypeID tinyint
ContType nvarchar(30)
ContNumFrom smallint
ContNumTo smallint
tblHaul
HaulID tinyint
Haul nvarchar(30)
I have the following InsertProcedure which seems to work fine...
dbo.usp_InsertContainer
(
@ContNum smallint,
@Length smallint,
@StopDistance smallint,
@ContType nvarchar(30),
@Haul nvarchar(30)
)
AS
INSERT INTO dbo.tblContainer(ContNum, Length, StopDistance, ContTypeID, HaulID)
SELECT
@ContNum
@Length
@StopDistance
(SELECT HaulID FROM dbo.tblHaul WHERE Haul=@Haul)
(SELECT ContTypeID FROM dbo.tblContTypes WHERE @ContNum BETWEEN ContNumFrom AND ContNumTo)
I have tried to code an usp_UpdateContainer:
(
@ContNum smallint,
@Length smallint,
@StopDistance smallint,
@ContType nvarchar(30),
@Haul nvarchar(30)
)
AS
UPDATE dbo.tblContainer
(SELECT HaulID FROM dbo.tblHaul WHERE Haul = @Haul),
(SELECT ContTypeID FROM dbo.tblContTyper WHERE @ContNum BETWEEN ContNumFrom AND ContNumTo),
SET
ContNum = @ContNum,
Length = @Length,
StopDistance = @StopDistance,
WHERE ContNum = @ContNum
Can you please guide me as to what I am doing wrong in the update procedure?
Thanks a bunch
Kind regards
Tina Nielsen, Denmark
|