CREATE TRIGGER TR1 ON dbo.sc
FOR INSERT
AS
select * from sc where 學號=(select 學號 from inserted)
CREATE TRIGGER TR2 ON dbo.sc
FOR delete
DECLARE @ErrNo int, @ErrMsg varchar(255)
if ( select count(*) from sc ) =1
begin
goto error
end
RETURN
error:
raiserror @errno @errmsg
rollback transaction
CREATE TRIGGER TR1 ON dbo.sc
FOR INSERT
AS
select * from sc where 學號=(select 學號 from inserted)
CREATE TRIGGER TR2 ON dbo.sc
FOR delete
AS
DECLARE @ErrNo int, @ErrMsg varchar(255)
if ( select count(*) from sc ) =1
begin
goto error
end
RETURN
error:
raiserror @errno @errmsg
rollback transaction