为什么sp_send_dbmail在SQL代理作业中失败?
我有一个简单的查询,当帐户被禁用30天以上时,我会运行它向我们的AD帐户pipe理员发送电子邮件通知。 当我自己运行它时,它工作得很好,以SA身份login,但在SQL Server代理作业中运行时失败。 以下是查询,replace了特定于业务的项目和对象名称: DECLARE @QueryString varchar(max) SET @QueryString = 'Select TrackingTable.Username FROM dbName.Schema.TrackingTable inner join dbName.Schema.viewName on DisabledAccounts.username = viewName.username WHERE DATEDIFF(dd,DateDisabled,GETDATE()) > 25 AND viewName.OU = ''InactiveAccounts''' EXEC msdb.dbo.sp_send_dbmail @profile_name = 'Profile', @body = 'This is the body text. Nothing interesting here. ', @recipients = '[email protected]', @subject='Account status update', @query = @QueryString, @importance […]