SP_Addmessage不会在事件日志中添加消息 [英] SP_Addmessage doesnot add the message in the event log

查看:124
本文介绍了SP_Addmessage不会在事件日志中添加消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

Hi All

sp_addmessage 50006 , 18 , 'error occurred while updating the variable value',  
@with_log = 'true',
@Replace='replace'

select * from sys.messages



此代码仅在sys.messages中添加消息.但是我也希望代码也将消息添加到事件日志中.任何人都可以帮助我.



This code adds the message only in sys.messages. But i want the code to add the message in event log also.Can anyone help me.

推荐答案

尝试不使用@replace或检查返回代码[0(成功)或1(失败)]

[@replace =]``替换''
如果指定为字符串替换,则现有错误消息将被新的消息文本和严重性级别覆盖. replace为varchar(7),默认值为NULL.如果msg_id已经存在,则必须指定此选项.如果您替换美国英语消息,则严重性级别将替换为所有其他具有相同msg_id的其他语言的消息.


我在MSDN上发现它需要sysadmin和serveradmin固定服务器角色的成员身份. (如果可能的话)
Try without @replace or check the return code [0 (success) or 1 (failure)]

[ @replace = ] ''replace''
If specified as the string replace, an existing error message is overwritten with new message text and severity level. replace is varchar(7) with a default of NULL. This option must be specified if msg_id already exists. If you replace a U.S. English message, the severity level is replaced for all messages in all other languages that have the same msg_id.


I found on MSDN that it requires membership in the sysadmin and serveradmin fixed server roles. (In case that may be the case)


这篇关于SP_Addmessage不会在事件日志中添加消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆