create trigger tri on table for insertasdeclare @s varchar(2)declare @s1 varchar(2)select @s=Sno,@s1=Cno from insertedif(select count(*) from table where Sno=@a and Cno =@s1)>0beginprint'已经存在'rollback transactionend