资源描述:
《通过数据库存储过程动态表头制作》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、这段代码在eTangent_AMS中….ALTERPROCEDURE[dbo].[ExpertGiveGraded]@PrizeGroupIDint,@AchievementFormintASBEGINdeclare@sql1nvarchar(500)declare@sql2nvarchar(500)declare@sql3nvarchar(max)declare@sql4nvarchar(500)declare@sql5nvarchar(max)declare@sql6nvarchar(500)declare@sql7nvarchar(500)declar
2、e@PartakeExpertNumintDeclare@GetprizeNumintset@sql1=''set@sql2=''set@sql3=''set@sql4=''set@sql5=''set@sql6=''set@sql7=''set@PartakeExpertNum=0select@GetprizeNum=count(Expert.Name)fromAchievementjoinParticipantsonParticipants.AchievementID=Achievement.AchievementIDjoinmarkonmark.Ach
3、ievementID=Achievement.AchievementIDjoinExpertonExpert.ExpertID=mark.ExpertIDwhereMark.PrizeRankRecommended=-1andPrizeGroupID=@PrizeGroupIDset@sql1='selectAchievement.FirstEvaluationNoas[初评编号],Achievement.HostNameas[申报人姓名],WorkUnitNameas[工作单位],TitleNameas[职称],DutyNameas[职务],Achieve
4、ment.AchievementNameas[成果名称],(Achievement.SerialNumber+Achievement.Publisher+Achievement.PublicationDate)as[成果发表期刊、出版单位名称以及成果发表、出版时间]'select@PartakeExpertNum=@PartakeExpertNum+1,@sql2=@sql2+',CONVERT(decimal(18,2),Score.['+CAST([ExpertID]ASnvarchar(256))+'评分])AS['+[Name]+'评分]',@sql
5、4=@sql4+',sum(caseExpertIDwhen'+cast(ExpertIDasnvarchar(5))+'thenTotalScoreend)as['+CAST([ExpertID]ASnvarchar(256))+'评分]'fromExpertwhereExpertIDin(selectExpertIDfromPrizeGroupExpertwherePrizeGroupID=@PrizeGroupIDandIsPartake=1)SELECT@sql7=@sql7+',isnull(sum(casePrizeRankRecommended
6、when'+cast(PropertyValueasnvarchar(50))+'thencountofpriseend),0)as推荐'+cast(PropertyMeaningasnvarchar(50))+'个数',@sql6=@sql6+',newprisecount.推荐'+PropertyMeaning+'个数'FROM(SELECTDISTINCTPropertyValue,PropertyMeaningfrommarkinnerjoinPropertyMappingonmark.PrizeRankRecommended=PropertyMap
7、ping.PropertyValuewhereachievementidin(selectAchievementIDfromAchievementwherePrizeGroupID=@PrizeGroupID)andPropertyMapping.PropertyName='PrizeRankRecommended'andPropertyMapping.PropertyValue!=-1)ASAset@sql3=',Convert(decimal(18,2),Achievement.AverageScore)as平均分,isnull(prisecount.c
8、ountofall,0)-isnull(nopris