sql insert operation in stored procedure

前端 未结 2 1895
清酒与你
清酒与你 2021-01-27 12:40

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          


        
相关标签:
2条回答
  • 2021-01-27 13:02

    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;
    
    0 讨论(0)
  • 2021-01-27 13:12

    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;
    
    0 讨论(0)
提交回复
热议问题