Tuesday 4 June 2013

how to write Prime number logic in sql server 2008

In this program i am going to give you code how to write prime number in sql server 2008.
prime number divisible by itself and by one.that we call as prime number.
i have shown here using while and if loop to check whether given number is prime or not

ALTER procedure [dbo].[prime_number]
(@@val int)
as
begin
declare @int int;
set @int=2;
while(@int < @@val)
          begin
if (@@val % @int=0)
            begin
            set @int=9;
break;
         end
          else
       set @int=@int + 1;
end
if (@int=9)
begin
print 'number is not prime number'
end
else
print  'NUMBER is prime number'
end

Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: