【问题标题】:How do I get the error description from an error code in SQL? [duplicate]如何从 SQL 中的错误代码中获取错误描述? [复制]
【发布时间】:2013-01-09 04:12:31
【问题描述】:

可能重复:
SqlError.Number descriptions

@@错误

这是一个整数。如何获得以下示例中错误的实际描述?

IF @@ERROR <> 0
INSERT INTO Table (ID, ErrorDescription)
VALUES (@ID, ????)

【问题讨论】:

标签: sql tsql error-handling


【解决方案1】:

因此,根据我评论中的参考,您可以如下所示:

SELECT @ErrorVariable AS ErrorID,
    text
FROM sys.messages
WHERE message_id = @ErrorVariable;

Using @@Error.

【讨论】:

  • 我不能只使用 ERROR_MESSAGE() 作为变量吗?
猜你喜欢
  • 1970-01-01
  • 2020-06-10
  • 2019-02-09
  • 1970-01-01
  • 1970-01-01
  • 2011-09-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多