@str4=stuff((select ', '+colname1 from (select distinct 1 as id , 't1.['+colname1+'], t1.['+colname1+']/convert(float,t2.['+colname1+']) as [n%]' as colname1 from temp_crosstable_001) t where id=t.id for xml path('')),1,1,'') @str4=stuff((select ', '+colname1 from (select distinct 1 as id , 't1.['+colname1+'], t1.['+colname1+']/convert(float,t2.['+colname1+']) as [n%]' as colname1 from temp_crosstable_001) t where id=t.id for xml path('')),1,1,'') ,