title: How can I set a parameter in a stored procedure based on if it's null or an empty string
body: <p>I've got a stored procedure that is inserting empty strings for certain values.</p>
  
  <p>Below is the relevant portion of the stored procedure.  You can see that if key2 is NULL then we set it's value based on key1.</p>
  
  <pre><code>IF NOT EXISTS (SELECT * FROM myTable WHERE key1 = @key1)
         INSERT INTO myTable (key1,key2)
         VALUES (@key1, ISNULL(@key2,'abc'+LTRIM(STR(@key1,7,0))));
  </code></pre>
  
  <p>What I'd like to be able to do is set key2 using the same formula if key2 is null or an empty string.</p>
  
  <p>For the sake of this question, let's assume I can't change the caller so I can get either an empty string or null in some cases, In the case where key2 isn't null or an empty string, then I want to insert it as is.</p>
  
  <p>I'm sure there is an easy way to do this, but I don't really know enough sql to know what to search for.</p>