Capturing multiple error messages from a single statement inside TRY CATCH

后端 未结 3 534
醉话见心
醉话见心 2020-12-06 01:52

I am running a batch of statements on several columns and tables and want to retrieve information on what errors occur.

The statement is a type change (varchar to nv

3条回答
  •  Happy的楠姐
    2020-12-06 02:29

    I know this is a bit old, but worth repeating here. This is a limitation of the error functions of sql, but looks like they are addressing for future versions.

    Social MSDN question - sql inner exception error

    Yes, this is a limitation of error_xxxxx() functions. When there are multiple error messages, they only give information about one of the messages - not always the most informative one.

    In the next version of SQL Server, codenamed Denali, there is a new command THROW which you can use in a catch handler, and which re-reraises the error, so you don't have to handle that yourself. When you use THROW, both errors will be reraised

提交回复
热议问题