Write a stored procedure that takes 2 numbers as input and swaps the numbers

Gow.Net
Posted by Gow.Net under Sql Server category on | Points: 40 | Views : 3622
create procedure sp_swap(@no1 int,@no2 int)
as
begin
set @no1=@no1+@no2
set @no2=@no1-@no2
set @no1=@no1-@no2
print @no1
print @no2
end


exec sp_swap 3,2

o/p:2,3

Comments or Responses

Posted by: Akiii on: 2/17/2012 Level:Bronze | Status: [Member] | Points: 10
Good work gowthaman , keep posting !


Thanks and Regards
Akiii
Posted by: Pandians on: 2/19/2012 Level:Silver | Status: [Member] [MVP] | Points: 10
Hi Gow.net

Nice Logic.. But, Is the stored procedure working ?

You can not even create the procedure... you have used (,) with PRINT statement... kindly change the script either...
print @no1

print @no2
(or)
Select @no1, @no2

Login to post response