SQL Server更改数据库兼容性级别时的错误日志

huangapple go评论66阅读模式
英文:

SQL Server error log on changing database compatibility level

问题

我们正在尝试捕获 SQL Server 数据库状态的更改,比如数据库兼容性的更改。我注意到在 SQL Server 2008 R2 中,当数据库兼容性发生更改时,会在 Windows 应用程序日志中记录事件 ID 5084。在 SQL Server 错误日志中,我还可以看到这条消息:“将数据库选项 COMPATIBILITY_LEVEL 设置为 XX,用于数据库 XXX”。

但在 SQL Server 2019 中却没有发生这种情况!我已经尝试了不同的服务器,结果都一样。如果我运行以下查询:

select *
from sys.messages
where message_id = 5084
and language_id = 1033

那么我可以看到 is_event_logged 列的值为 1。

我无法弄清楚为什么数据库选项的更改没有记录在 SQL Server 错误日志和 Windows 应用程序日志中。是否需要启用某个跟踪标志?有人可以提供帮助吗?谢谢。

英文:

We are trying to capture changes to SQL Server database status, such as changes to database compatibility. I'm seeing that in SQL Server 2008 R2, the Event ID 5084 is logged in Windows application log when there is a change to database compatibility. In SQL Server error log, I can also see this message "Setting database option COMPATIBILITY_LEVEL to XX for database XXX"

But this is not happening in SQL Server 2019! I've tried different servers with same results. If I run this query

select *
from sys.messages
where message_id = 5084
and language_id = 1033

then I can see the is_event_logged column = 1

I can't figure out why changes to database options are not logged in SQL Server error log and Windows Application log. Is there a trace flag I need to enable?

Can anyone help? Thanks.

答案1

得分: 0

我认为我已经找到了这个问题的原因 - 它在开发者版本中不起作用,我在企业版本中尝试过,它按预期工作。我认为它在标准版本中也会工作,但还没有测试过。

英文:

OK I think I've found the reason for this - it doesn't work in Developer Editions, I tried in Enterprise Edition and it worked as expected. I assume it would work with Standard Edition as well but haven't tested it yet.

huangapple
  • 本文由 发表于 2023年5月6日 21:10:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76189079.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定