Generating Output variables dynamically

I am trying to do following ang getting the error. Actually I am getting all the column names and also creating select statements dynamically during run time. I am required not to hardcode any values/ names. This execution will output everything as single text. that I will use.ques