For your column always fix,you can use follow code:
declare @sql nvarchar(max)
select @sql=isnull(@sql+',','')+''''+EmpName+'''' from Sample
select @sql = '''EmpName'','+@sql+' union select ''Empsalary'','
select @sql=isnull(@sql,'')+''''+convert(varchar(20),Empsalary)+''',' from...