Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP: problems running a query in xp_sendmail when defined as a JOB

Status
Not open for further replies.

alfredjp

Technical User
Joined
Jul 3, 2002
Messages
58
Location
JP
below is code snippet (which im assuming is the cause of the problem) from a certain stored procedure

Code:
EXEC Master.dbo.xp_sendmail
@dbuse = 'DanoneSSS',
@recipients = 'xxx@yyy.co.jp',
@subject = 'mmm nnn',
@message = @parMessage,
@query = 'SELECT CHECK_JS_CODE, CHECK_TYPE FROM T_CHECK_LOG WHERE CHECK_STATUS = 0 ORDER BY CHECK_ID',
@attachments = 'ResultSet.txt',
@attach_results = TRUE,
@no_header = TRUE,
@separator = '',
@ansi_attachment = TRUE

as in my case, when i execute this particular stored procedure, SQL Server sends me the email AND with the necessary attachment

however, when i create a Job with "EXEC dbo.SOSOStoredProcedure," though the Job executes successfully, no EMAIL is sent to me.

the funny thing is, when i comment out the following lines

Code:
@query = 'SELECT CHECK_JS_CODE, CHECK_TYPE FROM T_CHECK_LOG WHERE CHECK_STATUS = 0 ORDER BY CHECK_ID',
@attachments = 'ResultSet.txt',
@attach_results = TRUE,
@no_header = TRUE,
@separator = '',
@ansi_attachment = TRUE

the Job executes successfully with an EMAIL being sent to me

does SQL Server's job CANNOT handle xp_sendmail that returns a RESULT set? or i may be mistaken somewhere...

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top