We help IT Professionals succeed at work.

datatype hierarchyid

enrique_aeo
enrique_aeo asked
on
I have this procedure
CREATE PROCEDURE AddEmployee(@ManagerID hierarchyid, @EmpID int,
@LogID varchar(100), @JobTitle as varchar(200), @JoiningDate datetime)
AS
BEGIN
DECLARE @LastChild hierarchyid
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
BEGIN TRANSACTION

SELECT @LastChild = Max(OrgNode) From HumanResources.EmployeeDemo
WHERE OrgNode = @ManagerID

INSERT HumanResources.EmployeeDemo (OrgNode, EmployeeID, LoginID, Title, HireDate)
    VALUES(@LastChild, @EmpID,@LogID , @JobTitle, @JoiningDate)
COMMIT
END ;

como puedo usarlo?
I try this
DECLARE @Manager hierarchyid            
DECLARE @FirstChild hierarchyid
DECLARE @employeId hierarchyid
SELECT @Manager = CAST('/2/' AS hierarchyid)          
SELECT @FirstChild = @Manager.GetDescendant(NULL,NULL)              
SELECT @employeId = @Manager.GetDescendant(@FirstChild,NULL)              
print CONVERT(varchar, @employeId)
exec AddEmployee (@employeId,666,'adventure-works\elopez','SW Development', '04/08/73') ;

and i have this error
Incorrect syntax near '@employeId'.
Comment
Watch Question

Top Expert 2012
Commented:
>>como puedo usarlo?<<
Change this:
exec AddEmployee (@employeId,666,'adventure-works\elopez','SW Development', '04/08/73') ;
To this:
exec AddEmployee @employeId,666,'adventure-works\elopez','SW Development', '04/08/73' ;

And to be on the safe side format the data as yyyymmdd as in:
exec AddEmployee @employeId,666,'adventure-works\elopez','SW Development', '19730804' ;

Author

Commented:
Hello, I was sick a few hours I try your suggestion. Regards