Solved

strored procedure doesn't send mail on job but does when manually run

Posted on 2014-09-03
2
169 Views
Last Modified: 2014-09-03
I have this scheduled to run every 4 hours. The stored procedure it calls send an email and dumps data. The procedure dumps the data in ok but doesn't send an email using EXEC msdb.dbo.sp_send_dbmail with the job. The email sends when I manually run it however. Not sure what is wrong.


USE [db]
GO

DECLARE      @return_value int

EXEC      @return_value = [dbo].[UPDATE_my_STATS]

SELECT      'Return Value' = @return_value

GO
0
Comment
Question by:cseink
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 40300699
if it runs when started manually, but fails when running from a JOB, it's simply a permission problem (against the network!)

when running manually, you are running it with your logged in permissions
when running as job, it's the SQL agent process that runs by default under a localsystem permissions, which has NO permissions to do anything across the network. hence, you need to change this:
http://msdn.microsoft.com/en-us/library/ms191543.aspx
0
 

Author Closing Comment

by:cseink
ID: 40300706
Thanks! Didn't even think about that.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question