title: SQL User Defined Function Generates a Non-Boolean Type Error
body: <p>I'm getting this error on a SQL user defined function:</p>
  <blockquote>
  <p>An expression of non-boolean type specified in a context where a
  condition is expected, near ')'.</p>
  </blockquote>
  <p>For this:</p>
  <pre><code>UPDATE LMI_Contact
  SET Phone = NULL
  WHERE dbo.LMI_IsSingleCharacterRepeated(Phone, '0')
  </code></pre>
  <p>where the function can be created using:</p>
  <pre><code>-- ***this will also find NULL and empty string values***
  CREATE FUNCTION LMI_IsSingleCharacterRepeated (@string varchar(max), @char char(1))
  RETURNS bit
  AS 
  BEGIN
      DECLARE @index int
      DECLARE @len int
      DECLARE @currentChar char(1)
      SET @index = 1
      SET @len= LEN(@string)
  
      WHILE @index &lt;= @len
      BEGIN
          SET @currentChar = SUBSTRING(@string, @index, 1)
          IF @currentChar = @char
              SET @index= @index+ 1
          ELSE
              RETURN 0
      END
      RETURN 1
  END;
  GO
  </code></pre>
  <p>This function is for checking if a string is any specified single character, repeated.</p>