I realize that this is an older post but I discovered it just now when it came in the recent mailing.
My problem with this.
getting error on the following line:
CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) st
I have my compatibility set to 90.
Any ideas. I tried this in both 2005 and 2008