SQL笔记:触发器

时间:2021-01-27 05:05:57

触发器:

1、查看已有触发器
use yourdatabase
go
select * from sysobjects where xtype='TR'
2、查看单个触发器
  exec sp_helptext '触发器名'
3、删除触发器:
    drop trigger trigger_name

CREATE TRIGGER dbo.A_tri ON A
    FOR INSERT
AS
    BEGIN
        INSERT INTO dbo.B
                ( date, time, [0])
        SELECT  CONVERT(DATE, DTime) ,
                CONVERT(TIME, DTime) ,
                CASE WHEN tezheng= 0 THEN value
                     ELSE NULL
                END                 
        FROM    Inserted
    END
GO