• in my table, the column names are dynamic ..

    SQL does not work this way. By definition, the columns of a table are known and constant and it is time of creation. You are trying to fake an old file system in SQL and performance will suck rocks. We make fun of people with systems like this and refer to such things as the "automobiles, squids and Lady Gaga" table (or procedure or anything else in SQL that requires unknown structure). When I look at a column in your non-data model, it makes me want to ask, "on a scale from 1 to 10 what color is your favorite letter of the alphabet?"

    If you cannot get a consistent spec that fits into the relational model, then you are stuck with dynamic SQL which is the way you admit failure of your design or choice of RDBMS as a solution.

    What are you actually trying to do?

    Books in Celko Series for Morgan-Kaufmann Publishing
    Analytics and OLAP in SQL
    Data and Databases: Concepts in Practice
    Data, Measurements and Standards in SQL
    SQL for Smarties
    SQL Programming Style
    SQL Puzzles and Answers
    Thinking in Sets
    Trees and Hierarchies in SQL