下面的代码, 在兼容性级别90的所有用户数据库和tempdb库中都能执行, 但无法在系统数据库中执行, 执行会收到如下错误:
字串6
字串7
Msg 4121, Level 16, State 1, Line 2
字串8
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.f_test", or the name is ambiguous.
字串2
看来系统数据库中做东西有门槛了, 不过, 如果不在计算列中引用函数, 直接在查询中引用函数是没有问题的, 所以不知道是否应该算 BUG
字串6
CREATE FUNCTION dbo.f_test( 字串2
@value xml
字串3
)RETURNS int
字串7
AS 字串8
BEGIN 字串1
RETURN @value.value('(//*)[1]', 'int')
END
字串3
GO 字串9
字串4
字串4
字串3
CREATE TABLE #( 字串7
col1 xml, 字串7
col2 as dbo.f_test(col1) 字串4
)
GO 字串8
字串6
字串8
字串6
DROP TABLE # 字串5
DROP FUNCTION dbo.f_test
字串5