日期:2014-05-18  浏览次数:20494 次

求助,这样的触发器怎么写?
表dghouseprice字段,括号为字段类型:
newcode(nvarchar)      
iPriceAverage(int)    
bjrqyear(nvarchar)    
bjrqmonth(nvarchar)    
bjrqdate(nvarchar)
字段内容如下:
    newcode                 iPriceAverage         bjrqyear         bjrqmonth           bjrqdate
2007417170403               3700                         2007                 08                           09

当我在dghouseprice插入这条数据时,同时将其插入到另一个表househistoryprice中

另一个表househistoryprice的字段:
newcode(nvarchar)
historyprice(int)
ptime(datetime)
结果如下:
      newcode               historyprice             ptime
2007417170403               3700                   2007-08-09
这样的触发器怎么写?谢谢

------解决方案--------------------

Create Trigger TR_Insert_househistoryprice ON dghouseprice
After Insert
As
Insert househistoryprice Select newcode, iPriceAverage, GetDate() From Inserted
GO