2 xxyyzz521 xxyyzz521 于 2013.09.13 16:24 提问

sqlserver2005 存储过程不能返回 table吗?

这是存储过程中的一段sql

select * into #TB_JFFPTB1
from
(
select TB_JingFei.JF_MC,TB_JingFeiFenPei.JFFP_ID,TB_JingFeiFenPei.JF_KYYE,
TB_ZiYuanLeiBie.ZYLB_MC,TB_JingFeiQueRen.JFQR_ID,TB_JingFeiQueRen.GMSQ_ID,TB_JingFeiQueRen.JFQR_JE
from TB_JingFei
inner join TB_JingFeiFenPei
on TB_JingFei.JF_ID=TB_JingFeiFenPei.JF_ID and TB_JingFeiFenPei.JF_LB=1
left join TB_ZiYuanLeiBie
on TB_JingFeiFenPei.ZYLB_ID=TB_ZiYuanLeiBie.ZYLB_ID
left join TB_JingFeiQueRen
on TB_JingFeiFenPei.JFFP_ID=TB_JingFeiQueRen.JFFP_ID and TB_JingFeiQueRen.JFQR_JFLB=1
and TB_JingFeiQueRen.GMSQ_ID=8

where TB_JingFei.JF_NF='2013'
) Temp
declare @sql1 varchar(8000)
set @sql1 = 'select JF_MC as 经费名称'
select @sql1 = @sql1 + ' , max(case ZYLB_MC when ''' + ZYLB_MC + ''' then isnull(JF_KYYE,0) else 0 end) [' + ZYLB_MC + '] ,
max(case ZYLB_MC when ''' + ZYLB_MC + ''' then isnull(JFQR_JE,0) else 0 end) [确认' + ZYLB_MC + '],
max(case ZYLB_MC when ''' + ZYLB_MC + ''' then JFFP_ID else 0 end) [' + ZYLB_MC + 'ID],
max(case ZYLB_MC when ''' + ZYLB_MC + ''' then JFQR_ID else 0 end) [' + ZYLB_MC + 'QRID]'
from (select distinct ZYLB_MC from #TB_JFFPTB1) as a
set @sql1 = @sql1 + ' from #TB_JFFPTB1 group by JF_MC'
exec(@sql1)

出现的问题是,在sql2008中,会输出一张表,在sql2005中却没有输出结果,不明白为什么

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!