Home  >  Article  >  Database  >  如何将sql 执行的错误消息 记录到本地文件中

如何将sql 执行的错误消息 记录到本地文件中

WBOY
WBOYOriginal
2016-06-07 17:44:421333browse

其实大家都知道sql语句的错误信息都可以在sys.messages表里面找到 如: 如果在执行语句在try...catch中 我们可以通过以下方法获取错误信息。sql语句如下: BEGIN TRY TRY BEGIN CATCH ( 4000 ) ERROR_NUMBER() , @errorseverity = ERROR_SEVERITY() , @error

其实大家都知道sql语句的错误信息都可以在sys.messages表里面找到

如:

如果在执行语句在try...catch中 我们可以通过以下方法获取错误信息。sql语句如下:

BEGIN TRY TRY BEGIN CATCH (4000) ERROR_NUMBER() , @errorseverity = ERROR_SEVERITY() , @errorstate = ERROR_STATE() , @errormessage = ERROR_MESSAGE() SELECT @errornumber , @errorseverity , @errorstate , @errormessage RAISERROR ( , , ); END CATCH ,网站空间,服务器空间,香港虚拟主机

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn