Tuesday, March 20, 2012

calling another stored procedure within a stored procedure?

Hi, I have a while loop stored procedure, I need to send email for each item in the loop using a sendemail stored procedure. I have two question ..

1) I use EXEC PRODUCTION.DBO.SENDMAIL'email@.hotmail.com', 'Start', 'Job Start' in side the while loop stored procedure, but i didn't get any email or error msg. Why?

2) I try to move a file .. how do I find out if the moving is completed successfully?

-- MOVE FILES
SET @.CMD = 'MOVE /Y ' + '"' + @.ORIGINAL_FILE + '"' + ' "' + @.MOVE_FILE + '"'
EXEC master.dbo.xp_cmdshell @.CMD

Thanks for your reply in advance.

1. I have no idea for the stored procedure SENDMAIL. How did you define it?

2. The xp_cmdshell has only 2 return values: 0 or 1. so you can get the returned value as::

declare @.i bit

EXEC @.i=master.dbo.xp_cmdshell @.CMD

select @.i

Seehttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_xp_aa-sz_4jxo.asp for more information

|||Firstly try changing the email address to one internal to your domain - i had this problem with a system (although i wasnt sending from SQL i was sending from ASP.NET) but the problem ended up being the exchange server security policy not allowing sending to external addresses programatically. You can register the server with the exchange server to allow this i believe but this is something the server team did not me so i could say how to do it.|||Firstly try changing the email address to one internal to your domain - i had this problem with a system (although i wasnt sending from SQL i was sending from ASP.NET) but the problem ended up being the exchange server security policy not allowing sending to external addresses programatically. You can register the server with the exchange server to allow this i believe but this is something the server team did not me so i could not say how to do it.sql

No comments:

Post a Comment