title: The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator
body: <p>I created a procedure (using SQL Server 2008) to retrieve the image data from <code>image</code> table but this procedures giving me an error</p>
  
  <blockquote>
    <p>"The text, ntext, and image data types cannot be compared or sorted,
    except when using IS NULL or LIKE operator."</p>
  </blockquote>
  
  <p>My procedure is this:</p>
  
  <pre><code>Create procedure [dbo].[xp_GetImage]
  @companyId  udtId
  as  
  begin
  
  /*=============================================================================
  *   Constants
  *============================================================================*/
  declare 
          @SUCCESS            smallint,
          @FAILED             smallint,
          @ERROR_SEVERITY     smallint,
          @ERROR_STATE1       smallint,
          @theErrorMsg        nvarchar(4000),
          @theErrorState      int,
          @chartCount         int,
          @provider           varchar(128),
          @projectCount       int
  
  select  
          @SUCCESS    =   0,  
          @FAILED     =   -1, 
          @ERROR_SEVERITY = 11,
          @ERROR_STATE1 = 1
  
  begin try
  
      -- Get the Image
  
      select  Logo, LogoName,LogoSize
                from CompanyLogo                  
       where CompanyId = @companyId         
    order by Logo desc
  
  end try
  
  
  begin catch
      set @theErrorMsg = error_message()
      set @theErrorState = error_state()
      raiserror (@theErrorMsg, @ERROR_SEVERITY, @theErrorState)
      return (@FAILED)
  end catch
  end 
  print 'created the procedure xp_GetImage'
  go
  ---end of the procedure
  grant EXECUTE on xp_GetImage to public
  go
  </code></pre>
  
  <p>please help me.</p>