`
dengbaoleng
  • 浏览: 1124822 次
文章分类
社区版块
存档分类
最新评论

无法在SQL 2005系统数据库中执行的T-SQL语句(XML处理)

 
阅读更多

表现:

下面的代码, 在兼容性级别90的所有用户数据库和tempdb库中都能执行, 但无法在系统数据库中执行, 执行会收到如下错误:

Msg 4121, Level 16, State 1, Line 2

Cannot find either column "dbo" or the user-defined function or aggregate "dbo.f_test", or the name is ambiguous.

看来系统数据库中做东西有门槛了, 不过, 如果不在计算列中引用函数, 直接在查询中引用函数是没有问题的, 所以不知道是否应该算 BUG

CREATE FUNCTION dbo.f_test(

@value xml

)RETURNS int

AS

BEGIN

RETURN @value.value('(//*)[1]', 'int')

END

GO

CREATE TABLE #(

col1 xml,

col2 as dbo.f_test(col1)

)

GO

DROP TABLE #

DROP FUNCTION dbo.f_test

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics