我被动态sql代码使用了pivot。它很成功。但是当我创建存储过程但没有显示结果时 代码是
={filter(Sheet1!A2:C, len(Sheet1!A2:A)); filter(Sheet2!A2:C, len(Sheet2!A2:A)); filter(Sheet3!A2:C, len(Sheet3!A2:A))}
请帮忙
答案 0 :(得分:0)
您确定@cols
的部分可以修改为:
select @cols = STUFF(
(SELECT distinct ',' + QUOTENAME(Subject)
from mrkdetail
where Semester=@semester and RollNo>=@StartRoll and RollNo<=@EndRoll
FOR XML PATH('')),1,1,'')
并且还改变了这个:
Semester=''+@semester+'' and RollNo>='''+convert(varchar(200),@StartRoll,111)+''' and RollNo<='''+convert(varchar(200),@EndRoll)+'''
到此:
Semester='''+@semester+''' and RollNo>='+convert(varchar(200),@StartRoll)+' and RollNo<='+convert(varchar(200),@EndRoll)+'