- 爱易网页
-
MSSQL教程
- SQL串“ print” 不不来,怪哉,解决方法
日期:2014-05-17 浏览次数:20576 次
SQL串“ print” 不不来,怪哉,急急急急。。。
declare @sqlstr varchar(2500); --调试SQL
if(@countrowbefore = 0 and @countrowaccomplish = 0)
begin
print '执行到了3'
set @sqlstr= @sqlstr + 'select * ,'''+@EsName+'''+ as EsName,'''+@EsTypeName+''' as EsTypeName,'''+@EnergyTypeName+''' as EnergyTypeName,'+Cast(@EsPct as varchar(16))+' as EsPct,'+Cast(@ActPct as varchar(16))+' as ActPct,'''+@BuildingName+''' as BuildingName from
( select * from (select * from ESDataSumByHour where EsId='''+@EsId+''' and BuildingNo='''+@BuildingNo+''' and EnergyType='''+@EnergyType+''' and DADay='''+@DADayBefore+''' and (DateFlag =''A'' or DateFlag =''T'')) as pt
pivot (sum(SumQty) for DAHour in ([00],[01],[02],[03],[04],[05],[06],[07],[08],[09],[10],[11],[12],[13],[14],[15],[16],[17],[18],[19],[20],[21],[22],[23])) as rt
union all
select * from (select * from ESDataSumByHour where EsId='''+@EsId+''' and BuildingNo='''+@BuildingNo+''' and EnergyType='''+@EnergyType+''' and DADay='''+@DADayAccomplish+''' and DateFlag =''B'') as pt
pivot (sum(SumQty) for DAHour in ([00],[01],[02],[03],[04],[05],[06],[07],[08],[09],[10],[11],[12],[13],[14],[15],[16],[17],[18],[19],[20],[21],[22],[23])) as rt
) as rall '
print @sqlstr
print '执行到了3.1'
输出结果:
问题:怎么回事??? 中间的“ print @sqlstr”没有输出,而前后的标示都输出了。
交叉表怎么根据条件的显示结果有关问题