当数据有更新时,插入更新的数据
if exists(select name from sysobjects where name='insert_bill_Update_room' and TYPE='p')
drop procedure insert_bill_Update_room
go
create proc insert_bill_Update_room
@bd_Id varchar(10)
as
insert into tb_bill (b_Id,bd_Id,b_SumPrices,b_RateSumprices,b_Rate,b_Date,b_Time) values(@b_id,@bd_Id,@b_SumPrices,@b_RateSumPrices,@rate,@date,@time)
update tb_room set Din_Statu=@statu where Din_Id=@bd_Id
这样写对否。。。。
------解决方案--------------------
SQL code
这个问题应该建一个触发器:
go
create trigger tri_test on 插入数据的表
for insert
as
update 需要更新的表 b
set 字段=相关字段...... from inserted a where a.标识列=b.标识列