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
  • 2,691
  • 10
  • 30
  • 61
Luke101
  • 59,479
  • 80
  • 216
  • 348

4 Answers4

48

try including the schema id, as in

@lastchild = dbo.getlastchild(@root)
Mitch Wheat
  • 288,400
  • 42
  • 452
  • 532
SeaDrive
  • 3,932
  • 5
  • 31
  • 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
  • 156,697
  • 29
  • 278
  • 282
3

Try:

SELECT * FROM dbo.function(@parameters) 
Simple Sandman
  • 880
  • 3
  • 11
  • 34
Vijay Singh Rana
  • 990
  • 12
  • 32
3

Try

set @lastchild = dbo.getlastchild(@root)
Thomas
  • 7,835
  • 4
  • 36
  • 43