DECLARE @tablename as varchar(MAX);
  SET  @tablename = '[dbo].[A_E_att_rate]
                    ,[Acute_total_cost]
                    ,[Average_los]
                    ,[D_days]
                    ,[days_1000]
                    ,[rate]';
    WHILE (SELECT * from [dbo].[fnSplitListToTable](@tablename)) > 0
    BEGIN
    EXEC(' SELECT t.[Commissionercode],
                t.[RiskBand Qadm],
                x.Col,
                x.Value
                FROM' + @tablename +' t
            CROSS APPLY 
            (
                VALUES
                    (''August'', t.[Sum of Aug12-Jul13]),
                    (''July'', t.[Sum of Jul12-Jun13]),
                    (''June'', t.[Sum of Jun12-May13]),
                    (''May'', t.[Sum of May12-Apr13]),
                    (''April'', t.[Sum of Apr12-Mar13])
            ) x (Col, Value)')
END
Here in the above query i am trying to fetch the table names from the variable @tablename. Which is a comma separated value. I am interested in using this each table name with in the loop. How do i do this ?
 
    