我在 SQL Server 2008 R2 中有一个过程,我想将数据输入到 vol_Hours 列并在它不为空之前检查它,然后加上它在列中的旧数据条目,如果它是 NULL 然后将条目添加到不加 NULL 值的列。我不能添加 2+NULL,因为它 = NULL。我的代码是:
create procedure updateVolunteerHours
@vol_ID int, @vol_Hours int
As
if vol_Hours is NULL
-- vol_Hours it is the Column Name
Update Personal_Information set vol_Hours = @vol_Hours where vol_ID = @vol_ID
else
Update Personal_Information set vol_Hours = @vol_Hours + vol_Hours where vol_ID = @vol_ID