Add, Subtract,multiply,Divide in Store Procedure Sql Server



To Add,Subtract,Divide and Multiply We will use Following operator

Add (+) ,Subtract( -), Multiply (*), Divide (/)

Lets See how we can use it in Store Procedure





 Create Procedure SP_UpdateRecord --10,2
  (
  @numericvalue1 int,
  @numericvalue2 int
  )
  As
  Begin

  select (@numericvalue1-@numericvalue2) as SubtractionResult,
  (@numericvalue1+@numericvalue2) as AdditionResult,
  (@numericvalue1*@numericvalue2) as  MultiplicationResult,
  (@numericvalue1/@numericvalue2) as  DivisonResult

   end


Here We are Using two dynamic value in @numericvalue1 =10 and @numericvalue2=2
that will give us following Record



 SubtractionResult  AdditionResult MultiplicationResult      DivisonResult
           8                         12                             20                          5

No comments:

Post a Comment