update #temp
set #temp.Recycle=case when UnionA.num>0 then 1 else 0 end
from (select GradeID,sum(num)as num from AreaAllot
where CHARINDEX(@Area,AreaAllot.Area)=1 and LEN(@Area)=LEN(Area)-2
group by GradeID)UnionA inner join #temp
on UnionA.GradeID=#temp.GradeID
1、对于这个CHARINDEX今天纠结了很久才算弄明白是怎么个意思,为了以后忘记,所以大概的做一下笔记,
sql中的CHARINDEX和临时表,布布扣,bubuko.com
原文地址:http://blog.csdn.net/u011686207/article/details/29008415