0

所以我有一个 sql 存储过程:

CREATE PROC sp_SendConfirmedPurchasesEMail
(
    @RecID INT
)
AS
...
msdb.dbo.sp_send_dbmail
            @profile_name                   = @ProfileName,
            @recipients                     = @MailRecipients,
            @body                           = @MsgBody,
            @subject                        = @MailSubject,
            @body_format                    = @BodyFormat, 
            @importance                     = @MsgImportance, 
            @sensitivity                    = @MsgSensitivity, 
            @file_attachments               = 'Some File That Doesnt Exist',
            @query                          = @DBQuery,
            @execute_query_database         = @ExecuteQueryDatabase, 
            @attach_query_result_as_file    = @AttachQueryResultAsFile, 
            @query_attachment_filename      = @QueryAttachmentFilename,
            @query_result_header            = @QueryResultHeader,
            @query_result_width             = @QueryResultWidth,
            @query_result_separator         = @QueryResultSeparator,
            @exclude_query_output           = @ExcludeQueryOutput, 
            @append_query_error             = @AppendQueryError,
            @query_no_truncate              = @QueryNoTruncate,
            @copy_recipients                = @CC,
            @blind_copy_recipients          = @BCC,
            @reply_to                       = @ReplyTo,
            @from_address                   = @FromAddress
 END

当我在 SSMS 中运行它时出现错误:

Msg 22051, Level 16, State 1, Line 0
Attachment file <MyFileGoesHere> is invalid.

我想不通的是,为什么如果我在对“sp_send_dbmail”的调用周围放置 TRY/CATCH,我的捕获中没有错误?

4

0 回答 0