Create a table, then change this: -
EXEC (@SQL)
SELECT @SQL
To this: -
INSERT INTO yourTable
EXEC (@SQL);
If you're doing this to learn the syntax for a cursor, then ignore the next part of this post. Otherwise, you could remove the cursor altogether by building your dynamic SQL directly and concatenating with FOR XML. If you need help doing this, let me know.