title: Create function return integer SQL Server 2008
body: <p>I was trying to create a function which returns to an integer. However, I got the warning as </p>
  
  <pre><code>"Msg 2715, Level 16, State 3, Procedure median, Line 1 
  Column, parameter, or variable #0: Cannot find data type Median."
  </code></pre>
  
  <p>Here is the query. Thanks in advance.    </p>
  
  <pre><code>CREATE FUNCTION dbo.median (@score int)
  RETURNS Median
  AS
  BEGIN
  DECLARE @MedianScore as Median;
  SELECT @MedianScore=
  (
   (SELECT MAX(@score) FROM
     (SELECT TOP 50 PERCENT Score FROM t ORDER BY Score) AS BottomHalf)
   +
   (SELECT MIN(@score) FROM
     (SELECT TOP 50 PERCENT Score FROM t ORDER BY Score DESC) AS TopHalf)
  ) / 2 ;
  RETURN @MedianScore;
  END;
  GO
  </code></pre>