Friday 24 June 2016

What are the operators present in SQL SERVER


In this post we are going to see what are the operators present in the SQL SERVER.


o   Arithmetic Operators [+,-,*,/,%]
o   Logical Operators [ALL,AND,OR,ANY,BETWEEN,IN,EXISTS,LIKE]
o   Comparison Operators [=, <,>,>=, <=, <>,! =]
o   Assignment Operators [=]
o   Bitwise Operators [&, |,^]
o   Unary Operator [+,-,~]
o   Compound Operator [+=,*=,-=,/=,&=,^=,|=]


 Arithmetic Operators: 
   
DECLARE @A INT
DECLARE @B INT

SET @A = 1
SET @B = 2

SET @A = @A + @B
SET @A = @B - @A
SET @A = @A / @B
SET @A = @A % @B


  

  Logical Operators:

IF @A = 1 OR @B = 0  AND @A IN (1,2,3)
BEGIN 

   SELECT @A

END


 Comparison Operators:

                   IF @A = 1 OR @A != 2

                   IF @B <> 0 


 Assignment Operators:

                                    IF @A = 1


Bitwise Operators:

                                SELECT COLUMN1 & COLUMN2 FROM TABLENAME

Unary Operator:

                                SELECT ~COLUMN1 , ~COLUMN2 FROM TABLENAME


Compound Operator:

                                  SET @A += 2



From this post we can learn what are the operators present in the SQL SERVER.





No comments:

Post a Comment