declare @I int=2,@J int,@K bitwhile @I<100 begin set @J=2 set @K=1 while @J<@I-1 begin if @I%@J=0 set @K=0 set @J=@J+1 end if @K=1 print @I set @I=@I+1 end