title: SQL Server : check if variable is Empty or NULL for WHERE clause
body: <p>When searching for a list of products, the <code>@SearchType</code> parameter is optional. If <code>@SearchType</code> is empty or <code>NULL</code> then it should return all products and not use the <code>WHERE</code> clause. Otherwise, if it passed <code>Equipment</code> it would then use that instead.</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[psProducts] 
      (@SearchType varchar(50))
  AS
  BEGIN
      SET NOCOUNT ON;
  
      SELECT 
          P.[ProductId],
          P.[ProductName],
          P.[ProductPrice],
          P.[Type]
      FROM [Product] P
      -- if @Searchtype is not null then use the where clause
      WHERE p.[Type] = @SearchType
  END
  </code></pre>