You can run free-hand SQL in Infoview, but I don’t think that is your question. Your question seems to run along the lines of Stored Procedure, and in XI R2 it is not directly possible. Please find this forum note that explains SP in more detail to you: