Solved

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

Posted on 2014-09-03
2
179 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 143

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

685 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