title: How do check if a parameter is empty or null in Sql Server stored procedure in IF statement?
body: <p>I read this: <a href="https://stackoverflow.com/questions/334108/how-do-i-check-if-a-sql-server-string-is-null-or-empty">How do I check if a Sql server string is null or empty</a> but it not helped me in this situation.</p>
  
  <p>The piece of code from my stored procedure:</p>
  
  <pre><code>IF (@item1 IS NOT NULL) OR (LEN(@item1) &gt; 0)
          SELECT @sql = 'SELECT * FROM TEST1'
      ELSE
          SELECT @sql = 'SELECT * FROM TEST2'
   PRINT @sql;
  </code></pre>
  
  <p><code>@item1</code> is <code>NVARCHAR(1000)</code> type.</p>
  
  <p>When execute this stored procedure, I provided the value for <code>item1</code></p>
  
  <pre><code>EXEC    [dbo].[my_proc]
          @item1 = N''
  </code></pre>
  
  <p>it shows</p>
  
  <p><code>SELECT * FROM TEST1</code> // it is correct if <code>@item1 = N'some'</code></p>
  
  <p>instead of</p>
  
  <p><code>SELECT * FROM TEST2</code></p>
  
  <p>It is somewhere a function in sql to verify if a string is null or empty <strong>OR</strong> I made somewhere a mistake ?</p>
  
  <p>Like in C# -> <code>string.IsNullOrEmpty(myValue)</code></p>