Quantcast
Channel: SQL.ru: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 7251

sp_send_dbmail как достать текст ошибки

$
0
0
Добрый вечер.
Когда в параметре @file_attachments указан не верный путь к файлу процедура возвращает код ошибки "1". Как сожно достать текст ошибки?

DECLARE @mailitem_id INT,
        @retcode INT;

EXECUTE @retcode = msdb.dbo.sp_send_dbmail @profile_name = 'mail',
                                           @recipients = 'test@test.com',
                                           @subject = 'subj',
                                           @body = 'body',
                                           @body_format = 'HTML',
                                           @file_attachments = 'c:\tmp\test.pdf',
                                           @mailitem_id = @mailitem_id OUTPUT;


SELECT @retcode,
       @@error;


Сама "Management Studio" показыавет в закладке "Messages":
Msg 22051, Level 16, State 1, Line 0
Attachment file c:\tmp\test.pdf is invalid.

Viewing all articles
Browse latest Browse all 7251

Trending Articles