?
Solved

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

Posted on 2014-09-03
2
Medium Priority
?
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

741 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