存储过程中的sql插入操作 [英] sql insert operation in stored procedure

查看:39
本文介绍了存储过程中的sql插入操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于插入操作的存储过程.我尝试了以下操作,但它给了我错误.

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

给出错误 关键字 where 附近的语法不正确.

推荐答案

插入语法没有哪里".示例:

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;

这篇关于存储过程中的sql插入操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆