create  procedure zhishuhe(out sum int)
begin 
	declare number int default 2;
	declare temp int default 2;
	set sum = 0;
	while number<101 do 
		set temp = 2;
		label:while temp<number do 
			if number%temp=0 then 
				leave label;
			end if;
			set temp = temp+1;
		end while;
		if temp=number then 
			set sum = sum+number;
		end if;
		set number = number +1;
	end while;
end;
# 执行存储过程并查看结果
call zhishuhe(@sum);
select @sum;

删除存储过程:drop procedure if exists zhishuhe;