Writing SP

Hi I am novice in SQL development and want help on writing a procedure. My requirement is first I will get some data through a query and then for each record from the result need to run another query. Now for each record from that result set have to run a procedure. I am using CTE to get the result in first case but unable to proceed further.
Please help me in writing the logic. Thanks for your help.

Welcome to sql server world!

What you are trying to accomplish with these steps ?
Can you post your select query and the procedure ? because , depending of your requirement , maybe you can do this in one go.

sounds like you should read up on cursors. We all hate them but its the obvious way to do this kind of thing.

You'll wind up with something like this framework:

DECLARE cur CURSOR FOR (your query);
OPEN cur;

WHILE 1=1 BEGIN
     FETCH ....
     IF @@FETCH_STATUS <> 0 BREAK;
     -- process the row
     EXEC yourproc ...
END;

CLOSE cur;
DEALLOCATE cur;