Here is how I resolved the same problem.
Please do not kick me too hard
CREATE proc spIndexDefrag as
-- ////////////////////////////////////////////////////////////////////////////////////////
--
-- -- 2004-11-22
-- Defragment Indexes for all user-defined tables in the databases where
-- Index ScanDensity...