Let the storm money come!

触发器,禁止删除某记录

代码
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
-- =============================================
--
 Author:        <Author,,Name>
--
 Create date: <Create Date,,>
--
 Description:    <Description,,>
--
 =============================================
ALTER TRIGGER [dbo].[DenyDelete]
   
ON  [dbo].[tbsmstemplate]
   
for delete
AS 
BEGIN
    
-- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    
-- Insert statements for trigger here
    if exists (select 1 from deleted where fsmstemplateid in (22,23,24,25))   
    
begin   
        
RAISERROR ('不能删除id=0的记录'161)   
        
ROLLBACK TRANSACTION   
    
end   
END

 

posted @ 2010-04-07 20:31  精密~顽石  阅读(989)  评论(0编辑  收藏  举报
在通往地狱的路上,加班能使你更快到达。