Tuesday, March 19, 2013

prime number storedprocedure in SQL



Create procedure guna  @testprime int

as

begin

declare @i int
declare @reminder int
declare @messgae varchar(10)
set @messgae='Prime'
set @i=2

while (@i<@testprime)
begin

select  @reminder=@testprime%@i

if(@reminder=0)
begin
set @messgae='not prime'
break
end

set @i=@i+1
end

select @messgae

end



exec guna 4

No comments:

Post a Comment