I posted some code in this thread a while back
http://www.sqlservercentral.com/Forums/Topic1544629-146-1.aspx
http://www.sqlservercentral.com/Forums/FindPost1558835.aspx
this may be what you are looking for....but please read the comments from Jeff Moden after my post.
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day