create table #tb(db_element varchar(10),att_name varchar(10),att_value int)
insert into #tb
select '张三','a',2 union all
select '张三','b',6 union all
select '张三','c',7 union all
select '李四','a',5 union all
select '李四','b',4 union all
select '李四','c',3 union all
select '李四','d',2 union all
select '李四','e',5 union all
select '李四','f',6
declare @sql varchar(8000)
set @sql=''
select @sql=@sql+','+att_name from #tb group by att_name
set @sql=stuff(@sql,1,1,'')
set @sql='select * from #tb pivot (max(att_value) for att_name in ('+@sql+')) a'
exec(@sql)
drop table #tb