消息15197,级别16,状态1,过程sp_helptext,第107行

时间:2013-02-14 10:56:46

标签: sql-server-2008

我有一个名为dbo.CLRSPTest的程序,我加密了。当我执行该过程时,它会被执行但在我使用sp_helptext CLRSPTest查看代码时会抛出错误,即Msg 15197, Level 16, State 1, Procedure sp_helptext, Line 107 There is no text for object 'CLRSPTest'.

任何人都可以帮我解决???我很困惑。

1 个答案:

答案 0 :(得分:0)

sp_helptext

中的以下代码引发了此错误
 if (select count(*) from syscomments c, sysobjects o where o.xtype not in ('S', 'U')
     and o.id = c.id and o.id = @objid) = 0
   begin
     raiserror(15197,-1,-1,@objname) b
     return (1)
   end

这只是意味着syscomments中没有行的任何对象(不是表或系统对象)都将返回此错误。

加密对象在syscomments表中的记录在xtext字段中带有NULL,因此它们不会被早期代码捕获。您为这些对象获得的消息来自此查询。

if (select count(*) from syscomments where id = @objid and encrypted = 0) = 0
  begin
    raiserror(15471,-1,-1,@objname)
    return (0)
  end

现在为什么我们从第一个错误中获取错误而第二个错误没有错误...这可以通过检查master..sysmessages中的数据来解释。

select error, severity, description 
  from master..sysmessages 
 where error in (15197, 15471) 
   and msglangid = 1033

此查询返回:

error   severity    description
15197   16  There is no text for object '%s'.
15471   10  The text for object '%ls' is encrypted. 

在这里,我们看到错误15197的严重性为16,错误15471的严重性为10.在msdn上,解释了错误级别0-9未被“提升”,错误级别10被转换为错误级别0出于兼容性原因。

总而言之。 您收到此错误消息,因为您的过程是SQL CLR过程(它不会在syscomments表中获取任何记录)