/*新建job的sql语句可由sql server 对象资源管理器 Sql server代理中的作业->新建作业生成模板*/
/*sql server agent 服务要打开*/
create trigger tgr20161204 /*触发器名称*/
on [Kale].[dbo].[CardInfo]for update
as
if (update(RegUserId))/*RegUserId 列更改时触发触发器*/
begin
declare @newUserId int;
declare @oldUserId varchar(15);
declare @imsi varchar(15);
declare @date_time DATETIME;
select @newUserId = RegUserId, @imsi=IMSI, @date_time=OccupiedStartTime from Inserted;/*RegUserId 更改后的表*/
select @oldUserId = RegUserId from deleted;/*RegUserId 更改前的表*/
if (@newUserId > 0)
begin
/*开始新建job*/
/*begin add Job*/
/****** Object: Job [Job2016-12-04 20:35:01_UserId1] Script Date: 12/04/2016 21:03:20 ******/
BEGIN TRANSACTION
DECLARE @ReturnC