触发器!
控制输入内容的触发器。
比如:
CREATE TRIGGER T_Test ON [dbo].[Test]
Instead of Insert, Update -- For Insert, Updata也试过
AS
if Exists(Select Name from Inserted where Name
in (Select Name from Test)
)
Rollback Tran
这样写,数据根本没有办法写进去
应该怎么来写?
问题点数:20、回复次数:4Top
1 楼jinjazz(近身剪)回复于 2005-04-01 13:51:44 得分 9
CREATE TRIGGER trig_customerinfo_deleteupdate
ON customerinfo
FOR UPDATE
AS
If UPDATE(customerno)
BEGIN
select orderid from orderinfo where orderinfo.customerno = (select customerno from deleted)
if @@rowcount > 0
begin
RAISERROR ('不能修改编号,有相应的记录在订单表上', 16, 1)
ROLLBACK TRANSACTION
end
END
GOTop
2 楼cutelion(MADEinCNNC)回复于 2005-04-01 14:47:50 得分 0
学习!Top
3 楼yesyesyes()回复于 2005-04-01 16:56:53 得分 2
不用触发器,在name上建个唯一约束不就行了嘛Top
4 楼real_name(*真名)回复于 2005-04-02 10:13:36 得分 9
CREATE TRIGGER T_Test ON [dbo].[Test]
For Insert, Updata
AS
Select Name from Inserted where Name
in (Select Name from Test)
if @@rowcount>1
Rollback Tran
Top




