• http://www.sqlservercentral.com/scripts/Miscellaneous/31893/

    was written for sql 2005 but probably a decent place to start.