Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now