Reputation: 751
I have a stored procedure for insert operation.I tried the following but it gives me error.
ALTER PROCEDURE SetStaffSalary
@staffid int =0,
@amount int = 0
AS
SET NOCOUNT ON
BEGIN
begin
insert into AccStaff (totalSalary) values (@amount) where fk_staffID = @staffid;
end
END
gives error incorrect syntax near the keyword where
.
Upvotes: 0
Views: 69
Reputation: 156
there's no "where" on insert syntax. example :
insert into account (staffid, salary) values (@id, @salary);
or you could use update syntax to update the data.
update account set salary = @salary where staffid = @id;
Upvotes: 1
Reputation: 1136
try it like this - it looks like you want t do update
ALTER PROCEDURE setstaffsalary @staffid int = 0 ,
@amount int = 0
AS
BEGIN
UPDATE accstaff
SET totalsalary = @amount
WHERE fk_staffid
=
@staffid;
END;
Upvotes: 0