我有一个用于插入操作的存储过程。我尝试了以下但它给了我错误。
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
给出错误incorrect syntax near the keyword where
。
答案 0 :(得分:1)
插入语法没有“where”。 例如:
insert into account (staffid, salary) values (@id, @salary);
或者您可以使用更新语法来更新数据。
update account set salary = @salary where staffid = @id;
答案 1 :(得分:0)
尝试这样 - 看起来你想要更新
ALTER PROCEDURE setstaffsalary @staffid int = 0 ,
@amount int = 0
AS
BEGIN
UPDATE accstaff
SET totalsalary = @amount
WHERE fk_staffid
=
@staffid;
END;