title: Checking if a column has a null value tsql
body: <p>I'm trying to determine whether a product exists in the product table already. When I run this bit of tsql, it should return 1 and exit out of the proc, because the product id 7777 does not exist in the product table, but it's returning 0. If I run it without the if statement and just execute the select statement, it says that the <code>@prodID</code> is <code>null</code>. I'm wondering why is it not going into the if statement seeing as I am checking if it's a null value. Thanks in advance for any help.</p>
  
  <pre><code> Declare  @ProdID int
  
   select @ProdID = dbo.productTbl.ProductID
   from dbo.ProductTbl
   inner join dbo.OrderTbl
   on dbo.ProductTbl.ProductID = dbo.OrderTbl.ProductID
   where dbo.OrderTbl.ProductID = 7777
  
  
   if(@ProdID = null)
   begin 
   raiserror('The product does not exist',16,1)
   return 1
   end
   return 0
  </code></pre>