In this version of SQL Server as the error says "Only system functions and extended stored procedures can be executed from within a function." As a workaround you can use an INSERT to insert directly into dbmail.pipe table INSERT INTO master.dbmail.[pipe] (recipients, subject, message) SELECT billing_email, 'New invoice', 'You have a new invoice') FROM customer Hope this helps : Hi I am using MS SQL server on win 2003 and have been trying to run this : through query analizer using the the dbase Londonolink which is where the : user function is saved : Here is the fundction that has been created : CREATE FUNCTION mySendMail (@recipient VARCHAR (40), : @subject VARCHAR (255), : @message VARCHAR (8000) ) : RETURNS INT : AS : BEGIN : DECLARE @ret INT : EXEC @ret = master.dbmail.SendMAil @recipient, @subject, @message, : 'accounts@londonolink.net' : RETURN @ret : END : This is a the script I am trying to use where billing_email is a fiedl that : contans an email address : select dbo.mySendMail : (billing_email, : 'New invoice', : 'You have a new invoice') : From customer : --Where billing_email NULL : When the above line is not commeted out I get no error but no email is sent : However when I comment out I get the error below : Server: Msg 557, Level 16, State 2, Procedure mySendMail, Line 9 : Only functions and extended stored procedures can be executed from within a : function. : Hope this helps
|