日期:2014-05-18 浏览次数:21120 次
use WSCReview create table RiverBasinRecord ( RBR_ID int identity not null primary key, RiverBasinType char(2) not null check(RiverBasinType like '%[0-3][1-2%'), FatherRiverBasin int not null, RiverBasinName nvarchar(20) not null, unique(FatherRiverBasin,RiverBasinName) )
create trigger tri_insert_RBR on RiverBasinRecord for insert as if(select RBR_ID from RiverBasinRecord,inserted where RiverBasinRecord.RBR_ID=inserted.FatherRiverBasin)=null begin raiserror('没有找到所属流域',16,8) rollback transaction end go
use WSCReview create trigger tri_insert_RBR on RiverBasinRecord for insert as if(select RBR_ID from RiverBasinRecord,inserted where RiverBasinRecord.RBR_ID=inserted.FatherRiverBasin)=null begin raiserror('没有找到所属流域',16,8) rollback transaction end go 试试
------解决方案--------------------