27

I am wacking my head over the problem with this code.

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

It says it does not recognize getlastchild function. What am I doing wrong here?

Yulia V
  • 3,507
  • 10
  • 31
  • 64
Luke101
  • 63,072
  • 85
  • 231
  • 359

4 Answers4

49

try including the schema id, as in

@lastchild = dbo.getlastchild(@root)
Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
SeaDrive
  • 4,182
  • 5
  • 32
  • 30
13

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.

Adriaan Stander
  • 162,879
  • 31
  • 289
  • 284
3

Try:

SELECT * FROM dbo.function(@parameters) 
Simple Sandman
  • 900
  • 3
  • 11
  • 34
Vijay Singh Rana
  • 1,060
  • 14
  • 32
3

Try

set @lastchild = dbo.getlastchild(@root)
Thomas
  • 7,933
  • 4
  • 37
  • 45