TSD04151:未解析的对象[sys]的引用。[messages] [英] TSD04151: Unresolved reference to object [sys].[messages]
问题描述
我在成千上万的存储过程中有以下代码(作为错误处理的一部分):
I have the following code (as part of error handling) in thousands of stored proceduares:
select *
from sys.messages
where message_id = @ErrorNumber
and text <> '%s'
我收到了可怕的TSD04151警告。
I'm getting the dreaded TSD04151 warning.
另一个例子问题是我的地方
Another example of this problem is where i have
CREATE PROCEDURE Someschema.sOmeProc
@DataAccessUserName varchar(255)
EXECUTE AS USER = @DataAccessUserName
EXEC Someschema.sOmeOtherProc
REVERT
我得到了"有一个未解析的对象引用[@DataAccessUserName]"
and I get "has an unresolved reference to object [@DataAccessUserName]"
我添加了msdb和master dbschema引用,但是警告仍然存在。任何人都可以解释如何解决这个问题?我很想看到一些"真实"的东西。在我下次发布到生产之前的噪音中警告!
I've added both the msdb and master dbschema references, but the warnings persist. Can anyone shed some light on how to fix this? I'd love to see some "real" warnings in amongst the noise before my next release to production!
推荐答案
Hello Scott,
Hello Scott,
您可以尝试使用3部分标识符来引用它。因此,对于您的示例,您可以尝试master.sys.messages
You could try to reference it by using a 3 part identifier. So in the case of your example you could try master.sys.messages
请注意,您必须使用与向master添加引用时相同的名称或变量。
Please note that you have to use the same name or variable as when you added the reference to master.
此外,我发现有时候我不得不使用dbo。而不是系统。引用不提出警告。
In addition I found that sometimes I had to use dbo. rather than sys. for the reference to not raise a warning.
干杯,
史蒂文
这篇关于TSD04151:未解析的对象[sys]的引用。[messages]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!