Hi,
since MS SQL Server is not used in UCCX anymore, I assume you are talking about Cisco ICM.
It has already a system implemented that periodically checks the size of tables and removes old data according to the schedule.
I don't really see the meaning of index "defragmentation", as data is written sequentially to the historical tables. You can rebuild the index of the configuration tables, if, for instance, agents are added and removed frequently.
G.