sqlserver2008 触发器备份 20170811

-------------触发器-----------------------------------------------base-----NO
if (object_id('trigger_JP_STUDENT_TEMP_insert', 'tr') is not null)
    drop trigger trigger_JP_STUDENT_TEMP_insert
go
create trigger trigger_JP_STUDENT_TEMP_insert
on JP_STUDENT 
    for insert
as
    begin
        insert  into JP_STUDENT_TEMP  select  top 1 * from JP_STUDENT order by ID desc;
    end
go




-------------トリガ-----------------------------関数:テスト版---使用しない、学生と銀行交互
if (object_id('trigger_JP_STUDENT_TEMP_insert', 'tr') is not null)
    drop trigger trigger_JP_STUDENT_TEMP_insert
go
create trigger trigger_JP_STUDENT_TEMP_insert
on JP_STUDENT 
    for insert
as
        begin
            insert  into JP_STUDENT_TEMP  select  top 1 * from JP_STUDENT order by ID desc;
        end
go




use jp_base;
-------------トリガ-------------------------------関数:一般から、学生と銀行交互、使用しない
------ターミナルを発行すると、手動で除外するためにデータを追加します,一時テールに追加しないJP_STUDENT_TEMP---------
if (object_id('trigger_JP_STUDENT_TEMP_insert', 'tr') is not null)
    drop trigger trigger_JP_STUDENT_TEMP_insert
go
create trigger trigger_JP_STUDENT_TEMP_insert
on JP_STUDENT 
    for insert
as
    declare @TRAIN_COMPANY_ID int;
    select @TRAIN_COMPANY_ID=TRAIN_COMPANY_ID from inserted;
    if (exists(select * from JP_XTConfig where  schoolid>0  AND keyval=1 AND  schoolid = @TRAIN_COMPANY_ID))
        begin
            insert  into JP_STUDENT_TEMP  select  top 1 * from JP_STUDENT order by ID desc;
        end
    else  print  '';
go




use jp_base;
-------------トリガ--------------関数:最適化されたこりつ、学生はと銀行交互
------ターミナルを発行すると、手動で除外するためにデータを追加します,一時テールに追加しないJP_STUDENT_TEMP--------使用です
---------------TRAIN_COMPANY_IDとISBANKSTUDENTは使用から------------------
---------------作成者:ちんひ------------------
---------------作成の時間:2016年05月10日------------------
if (object_id('trigger_JP_STUDENT_TEMP_insert', 'tr') is not null)
    drop trigger trigger_JP_STUDENT_TEMP_insert
go
create trigger trigger_JP_STUDENT_TEMP_insert
on JP_STUDENT 
    for insert
as
    declare @TRAIN_COMPANY_ID int;
    declare @ISBANKSTUDENT int;
    select @TRAIN_COMPANY_ID=TRAIN_COMPANY_ID from inserted;
    select @ISBANKSTUDENT=ISBANKSTUDENT       from inserted;
    if (exists(select * from JP_XTConfig where  schoolid>0  AND keyval=1 AND  schoolid = @TRAIN_COMPANY_ID)  AND  @ISBANKSTUDENT=0)
        begin
            insert  into JP_STUDENT_TEMP  select  top 1 * from JP_STUDENT order by ID desc;
        end
    else  print  '';
go


use jp_base;
-------------トリガ--------------関数:自動に前のデータバインディングを削除する-----------------使用です
---------------IDと作成の時間は使用から------------------
---------------作成者:ちんひ------------------
---------------作成の時間:2016年06月24日------------------
if (object_id('trigger_JP_Coach_Student_BD_insert', 'tr') is not null)
    drop trigger trigger_JP_Coach_Student_BD_insert
go
create trigger trigger_JP_Coach_Student_BD_insert
on JP_Coach_Student_BD 
    for insert
as
    declare @sid nvarchar(100);
    declare @CreatTime datetime;
    select @sid=sid from inserted;
    select @CreatTime=CreatTime  from inserted;
    if (1>0)
        begin
            delete from JP_Coach_Student_BD where  sid=@sid and CreatTime<>@CreatTime;
        end
    else  print  '';
go
-----------------------------------------ここまで------------------------------------

 

posted @ 2017-08-11 11:12 araki 阅读(...) 评论(...) 编辑 收藏