title: SQL CASE Statement
body: <p>Is the following possible in SQL Server 2000?</p>
  
  <pre><code>CREATE FUNCTION getItemType  (@code varchar(18))
  RETURNS int
  AS
  BEGIN
  Declare @Type tinyint
  Select @Type = case len(@code)
  WHEN 12,14,17 THEN 1
  WHEN 13,15,18 THEN 2
  WHEN 8,10 THEN 3
  ELSE  0
  END
  RETURN (@Type)
  END
  </code></pre>
  
  <p>Thanks.</p>