title: Select union only if @variable is emply, using SQL stored procedure
body: <p>I have a stored procedure with the following UNION SELECT. I want the second select to run only if @name is empty. </p>
  
  <pre><code>CREATE PROCEDURE [dbo].[spNames]
  @name NVARCHAR(20)
  AS
  SET NOCOUNT ON;
  SELECT names FROM namesTbl1
  UNION SELECT names FROM namesTbl2 //This should run only if @name = ''
  </code></pre>
  
  <p>Any help is appreciated</p>