Get as copy of TREES & HIERARCHIES IN SQL and read the sections of BOM. It uses the Nested Sets model and will run a lot better than what you are trying to do.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in Sets / Trees and Hierarchies in SQL