Ok there is this that may be worth looking at http://www.sqlservercentral.com/Forums/Topic1237043-392-1.aspx
Which discusses a similar problem and may be adaptable to your needs.
_________________________________________________________________________
SSC Guide to Posting and Best Practices