2010-04-20 57 views
23

我正在用這段代碼來解決問題。如何調用存儲過程中的標量函數

DECLARE @root hierarchyid 
DECLARE @lastchild hierarchyid 
SELECT @root = NodeHierarchyID FROM NodeHierarchy WHERE ID = 1 
SET @lastchild = getlastchild(@root) 

它說它不識別getlastchild函數。我在這裏做錯了什麼?

回答

44

嘗試包括架構ID,如

@lastchild = dbo.getlastchild(@root) 
+16

+1你**不能**調用在SQL Server 2008用戶定義的函數,而無需使用現在的模式 – 2010-04-20 17:20:01

+0

謝謝you..It工作 – Luke101 2010-04-20 23:07:48

+0

但是,不要忘記「SET」,例如'SET @lastchild = ...' – STLDeveloper 2016-03-11 16:37:04

3

嘗試

set @lastchild = dbo.getlastchild(@root) 
11

使用

set @lastchild = dbo.getlastchild(@root) 

CREATE FUNCTION

使用標量表達式的標量值函數 ,包括計算列的 和CHECK 約束定義。 當調用標量函數 時,至少使用 函數的兩部分名稱。

2

嘗試:

SELECT * FROM dbo.function(@parameters) 
相關問題