title: how to take all values from sql table column on condition?
body: <blockquote>
    <p>I want to select all column values irrespective of NULL as column value</p>
  </blockquote>
  
  <p>my problem is when i try to select values using IS NULL i'm getting such records also thise having NULL as a value :(   </p>
  
  <pre><code>declare @status varchar(50)=NULL
  declare @path varchar(50)= 'India'
  
  select 
  *
  from [vwMYDATA] 
  where
  Path like '%' + @path + '%' and
  (Status = @status or @status IS NULL)
  </code></pre>
  
  <p>vwMYDATA</p>
  
  <pre><code>path    status
  INDIA1  NULL  
  INDIA2  close
  INDIA3  open
  </code></pre>
  
  <p>If i execute above query i'm getting all records whose status column has NULL value</p>
  
  <blockquote>
    <p>expected is if no status value specified show all status records</p>
  </blockquote>
  
  <pre><code>path    status
  INDIA1  NULL  
  INDIA2  close
  INDIA3  open
  </code></pre>
  
  <p>it is showing </p>
  
  <pre><code>path    status
  INDIA1  NULL  
  </code></pre>
  
  <p>I'm passing these 2 parameters to stored procedure which is having this select statment.</p>
  
  <p>please help me to filtered out and show all the records if status is not given as input</p>