2015-05-24 46 views
1

我有一个具有1行 表1更新生成两行

____________________________________________ 
id_employee | month| year| score| nbr_month| 
____________________________________________ 
14   | 2 |2015 | 15 | 4  | 
____________________________________________ 

,我想更新该行 所以我创造了我的存储过程

update table 1 
set score=10,nbr_month=4 
where id_employee=14 and month=2 and year=2015 

一个表,但的结果存储过程的执行生成另一行

____________________________________________ 
id_employee | month| year| score| nbr_month| 
____________________________________________ 
14   | 2 |2015 | 15 | 4  | 
14   | 2 |2015 | 10 | 4  | 
____________________________________________ 

那么请在哪里问题? 预先感谢您。

存储过程:

ALTER proc [dbo].[update_score] 
@id_employee int, 
@score int, 
@nbr_month int, 
@month int, 
@year int 
as 
begin 
    update table1 
    set score = @score 
     ,nbr_month = @nbr_month 
    where id_employee = id_employee 
    and [month] = @month 
    and [year] = @year 
end 
+0

不,“更新”从不创建新记录。一个'insert'就行了。 –

+0

检查存储过程或者表中是否有触发器。 – DavidG

+1

你可以显示存储过程的定义吗? –

回答

1

那是不可能的。更新修改已有的记录。所以你的代码可能会运行一个insert命令。或者调用一个相同的存储过程。或者触发一个trigger。但当然,update不会生成新记录。

0

有可能是更新触发器写在table.thats否则它不能。