CREATE TRIGGER 个税计算 ON dbo.工资明细
FOR UPDATE,INSERT
AS
declare @K double
if Update(应发工资) or Update( 扣除社保)
begin
set @K= (b.应发工资 - b.扣除社保) - 3500
if @K >= 4000 and @K < 5000 then
end
if @K >= 5000 and @K < 6000 then
@j = 45
if @K >= 6000 and @K < 8000 then
@j = 145
if @K >= 8000 and @K < 9000 then
@j = 345
if @K >= 9000 and @K < 10000 then
@j = 545
if @K >= 10000 and @K < 15000 then
@j = 745
if @K >= 15000 and @K < 19000 then
@j = 1870
if @K >= 19000 and @K < 20000 then
@j = 2870
if @K >= 20000 and @K < 38600 then
@j = 3120
if @K >= 38600 and @K < 50000 then
@j = 7775
if @K >= 50000 and @K < 70000 then
@j = 11195
if @K >= 70000 then
@j = 17770
Update 工资明细
set 扣除所得税 = @j
from 工资明细 a,Inserted b
where a.ID = b.ID15
end
实现目的是想SQL服务器,当修改表列应发工资或扣除社保字段数据时,触发产生自动计算所得税。请教以上如何修改才能实现?先谢了!!