读书人

这样的触发器如何写

发布时间: 2012-01-10 21:26:50 作者: rapoo

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

读书人网 >SQL Server

热点推荐