title: SQL Stored procedure if (@variable = 0) doesn't work
body: <p>I've created a Stored procedure with some variables and a nested if statement.
  When I call the Stored procedure from my program and check the returned dataset for the returned values, my dataset is empty while there should be records in it. After some testing I noticed when the statement if (@PoolID = 0) is tested and @PoolID is 0, it won't go trough the if statement... So whenever I set the variable poolid to 0 in my code I get the results from the else statement...</p>
  
  <p>Anybody who knows what's going wrong?
  Thx</p>
  
  <pre><code>set ANSI_NULLS ON
  set QUOTED_IDENTIFIER ON
  GO
  ALTER PROCEDURE [dbo].[Pool_select]
  
  @PartnerCode nvarchar(8),
  @GebrID int,
  @PoolID int,
  @Bevoegdheid int
  
  AS
  
  IF (@PoolID = 0)
  BEGIN
      IF (@Bevoegdheid &lt; 3)
      BEGIN
          SELECT
          p.*,
          pr.poolrecht
          FROM racpPool p, racpPoolrecht pr
          WHERE
          p.poolid = pr.poolid and
          p.PartnerCode = @PartnerCode and
          pr.poolrecht &gt; 0 and
          p.actief = 1 and
          pr.GebrID = @GebrID
      END
      ELSE
      BEGIN   
          SELECT *
          FROM racpPool p
          WHERE standaardpool = 1
          and partnercode = @PartnerCode
      END     
  END
  ELSE
  BEGIN
      IF (@Bevoegdheid &lt; 3)
      BEGIN
          SELECT
          p.*,
          pr.poolrecht
          FROM racpPool p, racpPoolrecht pr
          WHERE 
          p.poolid = pr.poolid and
          p.PartnerCode = @PartnerCode and
          pr.poolrecht &gt; 0 and
          p.actief = 1 and
          pr.GebrID = @GebrID and 
          p.PoolID = @PoolID
      END
      ELSE IF (@Bevoegdheid &gt;= 3)
      BEGIN   
          SELECT *
          FROM racpPool p
          WHERE PoolID = @PoolID
      END 
  END 
  </code></pre>