Do you mean you're generating Dynamic SQL? Where is this variable you are wanting to "store" the dynamic SQL in, SSIS or SQL Server (if the latter, then surely you already have a variable as you're executing dynamic SQL with
sp_executesql). If you do want to store the value in SSIS, do these statements return any other datasets?
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.