Hi
as a start, suggest you read the article below...it seems to be very clsoe to what you are asking and will explain the method far better than I can.
http://www.sqlservercentral.com/articles/T-SQL/88244/
if you still have issues, please post back.
kind regards
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day