determine if number is even or odd

The following source codes describes a method in T-SQL to determine if a given integer is even or odd. For the example the number seven is used and of course it is odd.

DECLARE @count as int
SET @count = 7

SELECT
  CASE 
    WHEN @count % 2 = 1 THEN 'odd'
    ELSE 'even'
  END
-- odd

Comments

There were no comments found for this weblog.

Du mußt Dich einloggen um diesen Weblog kommentieren zu können!