gpt4 book ai didi

sql-server - sys.sql_modules 和 sys.objects 中的 object_name 和定义关系错误

转载 作者:行者123 更新时间:2023-12-04 13:16:26 25 4
gpt4 key购买 nike

我运行了以下查询

SELECT sm.object_id,
v1.object_name,
o.type,
o.type_desc,
sm.definition
FROM sys.sql_modules sm
CROSS APPLY (VALUES (OBJECT_NAME(sm.object_id))) v1 (object_name)
JOIN sys.objects o ON sm.object_id = o.object_id;

并且在 object_name之间存在三个错误关系的对象和 definition .名称和它引用的定义之间没有匹配,也没有对应关系。

enter image description here

看起来这个表没有跟踪这三个对象的名称和定义的删除或更改。

这种情况怎么能给出呢?
如何“更新”此表或正确修复此问题?

Query results updated

最佳答案

这是使用“sp_rename”的副作用。
这些对象可以正常工作,但要刷新它们的定义,您需要重新创建它们。

来自 sp_rename文档:

Renaming a stored procedure, function, view, or trigger will not change the name of the corresponding object either in the definition column of the sys.sql_modules catalog view or obtained using the OBJECT_DEFINITION built-in function. Therefore, we recommend that sp_rename not be used to rename these object types. Instead, drop and re-create the object with its new name.

关于sql-server - sys.sql_modules 和 sys.objects 中的 object_name 和定义关系错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59949317/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com