I am wacking my head over the problem with this code.
DECLARE @root hierarchyid
DECLARE @lastchild hierarchyid
SELECT @root = NodeHierarchyID FROM NodeHierar
try including the schema id, as in
@lastchild = dbo.getlastchild(@root)
Try:
SELECT * FROM dbo.function(@parameters)
Try
set @lastchild = dbo.getlastchild(@root)
Use
set @lastchild = dbo.getlastchild(@root)
From CREATE FUNCTION
Scalar-valued functions may be invoked where scalar expressions are used, including computed columns and CHECK constraint definitions. When invoking scalar-valued functions, at minimum use the two-part name of the function.