title: Why does this T-SQL function always return true?
body: <p>I wrote this function and now its always returning true...<br>
  can anybody help me?</p>
  
  <pre><code>
  Create FUNCTION dbo.ValidateBranch
  (
      @BranchID   nvarchar(50),
      @Password   nvarchar(50)
  )
  RETURNS bit
  AS
      BEGIN
      declare @Res bit
  
      if exists(Select * From TPasswords Where (BranchID = @BranchID) and (isSecurity = 0) and (Pass = @Password)) 
          set @Res = 1
      else
          set @Res = 0
  
  
  
      RETURN @Res
      END
  </code></pre>
  
  <p>and i'm callign like so:</p>
  
  <pre><code>
  bool isValidBranch = taQueries.ValidateBranch(IDBranch, PasswordTextBox.Text) ?? false;
  </code></pre>