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

来源:互联网 发布:饥荒修改软件 编辑:程序博客网 时间:2024/05/16 14:23

表现:

下面的代码, 在兼容性级别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

 


表现:

下面的代码, 在兼容性级别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

 


原创粉丝点击