select @sql = @sql + '
select 编号=fld_xysbh
,产品名称=max(case when fld_zh=1 and fld_th=1 and fld_kh=0 and fld_xh=1 then fld_xmnr else '''' end)
,产品型号=max(case when fld_zh=1 and fld_th=2 and fld_kh=0 and fld_xh=1 then fld_xmnr else '''' end)
,功能=max(case when fld_zh=1 and fld_th=4 and fld_kh=0 and fld_xh=1 then fld_xmnr else '''' end)
。。。。。。。。。。。。。。。。。。。。。
from xys.dbo.'
+ name + ' group by fld_xysbh' + ' union all '
from xys.dbo.sysobjects where xtype='u' and name like 'tab[_]xmnr%'
if len(@sql) > 10
begin
set @sql = left(@sql, len(@sql) - 10)
exec(@sql)
end