Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共1 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:求教有关SQL触发器编写

1楼
baoxyang 发表于:2011/12/28 20:35:00

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服务器,当修改表列应发工资或扣除社保字段数据时,触发产生自动计算所得税。请教以上如何修改才能实现?先谢了!!

 

共1 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .03125 s, 2 queries.