I am creating a named query to only get certain columns from a table (mssql) based on the requirement. I can parametrized the where conditions but was not sure if there was a way to parametrized the column names. For example - in some cases I want column1 but in other cases I want column1, column2 and in some cases only column3. Or my option is to use system.db.runPrepQuery and create dynamic select statement.
It sounds like you are scripting this, so your named query could return all of the columns, and then the resultant dataset could be subsequently filtered in the script using system.dataset.filterColumns