Dynamic Query

  • I have the Data in this format in my temporary table.Column1 contains the TableName and Column2 contains the ColumnName in that Particular table.

    Tele callcount

    Tele staffcount

    Sche call count

    Sche callcount

    Here callcount,StaffCount are the names of the columns in the Tele table as well as in the MetricTable.

    The Data in the Tele Table and the Sche Table looks similar to this

    BatchID,callcount,staffcount,ID

    200,5,45,12215

    201,6,12,12215

    Now I need to get the Columnname in my temporary table and based on the Column name i need to get the value in that particular column without using loops and cursors. Can this be done in SQL?

  • Yes, it can be done in SQL.

    Check out "dynamic SQL" on Google.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply