I don't think you require a CURSOR to do this kind of stuff
Please go through the article in my signature and give us the DDL of the tables involved, some sample data and the expected results along with a brief description of your problem.
I am sure you will get a solution without using a CURSOR
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/