从SAS插入时,SQL触发器不会触发

时间:2016-07-30 16:18:34

标签: sql-server triggers sas

USE [dbname]
   GO
   SET NOCOUNT ON
   GO
   ALTER TRIGGER [dbo].[my_trigger]  
   ON [dbo].[Table_1]  
   AFTER INSERT, UPDATE, DELETE   
   AS  
   EXEC  msdb.dbo.sp_send_dbmail
          @recipients = 'xx@companyid.com', 
          @profile_name = 'PQM',
          @subject = 'Data Inserted', 
          @body = 'Hi Data has been inserted';
   GO  

当我从SQL Server管理工作室或使用VBA代码插入时,执行此代码并触发邮件。但是,当我从SAS服务器端插入邮件时,不会触发邮件。

SAS编码

proc sql noprint;
connect to odbc as sql1(datasrc= PQMDB USER= 'XXXX' PASSWORD = 'XXXX');
create table tr as select * 
from connection to sql1
  (insert into dbname.dbo.Table_1 values('abc1');
disconnect from sql1;
quit;

当我在SQL端禁用触发器时,此代码执行正常。

1 个答案:

答案 0 :(得分:0)

不得不在SAS端进行操作并使用“< connectionname >的执行();这有助于并且sql现在正在触发触发器