下面的代碼, 在兼容性級(jí)別90的所有用戶數(shù)據(jù)庫(kù)和tempdb庫(kù)中都能執(zhí)行, 但無法在系統(tǒng)數(shù)據(jù)庫(kù)中執(zhí)行, 執(zhí)行會(huì)收到如下錯(cuò)誤:
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.
看來系統(tǒng)數(shù)據(jù)庫(kù)中做東西有門檻了, 不過, 如果不在計(jì)算列中引用函數(shù), 直接在查詢中引用函數(shù)是沒有問題的, 所以不知道是否應(yīng)該算 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
新聞熱點(diǎn)
疑難解答
圖片精選