You could try to use a loop. As you will get many levels of recursion with your approach:
declare @child int = 0
declare @parent int = 1 --child to search
while @child <> @parent
BEGIN
set @child = @parent
select @parent = Parentid from @parentchild where ChildID = @child
END
select @parent