表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
这样的触发器怎么写?谢谢

解决方案 »

  1.   


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

  2.   

    最後修改Create Trigger TR_Insert_househistoryprice ON dghouseprice
    After Insert
    As
    Insert househistoryprice Select newcode, iPriceAverage, bjrqyear + '-' + bjrqmonth + '-' + bjrqdate From Inserted Where iPriceAverage != 0
    GO