SQL Server: select data from between a range of dates if dates exist, if not return all data
  
 
     
     
             
                 
 
 
         up vote 
         0 
         down vote 
 
         favorite 
         
 
 
 
 
 
             
 
             
 
     
 
 @dateFrom  and @dateTo  are the variables coming from outside users. They may can put a date in, or choose not to have any range and want to see all data,   SELECT  *  FROM tbl  WHERE --    I want to implement following conditions    If @dateFrom  and @dateTO  both variable have values, then select data in range  If @dateFrom   has value and @dateTo  don't, then select data range starting from @dateFrom  with no ending range.  If @dateTo  has value and @dateFrom  don't, then select data range ending at @dateTo  with no starting range.  If non of the variable exist, return all the data.   
 
         
             
                 sql sql-server tsql 
             
         
 
     
         
             
  share | improve this question  
             
 
                 
 
     
         edited...