title: Where Clause with IN and Coalesce
body: <p>Say I have a table, Music:</p>
  
  <pre><code>Genre          Artist              Song
  Rock           Rolling Stones      Brown Sugar 
  Rock           Bob Seger           Night Moves
  Country        Eric Church         Record Year
  Pop            Bruno Mars          Grenade
  </code></pre>
  
  <p>And I have</p>
  
  <pre><code>DECLARE @Genre VarChar(MAX) = NULL
  DECLARE @Artist VarChar(MAX) = NULL
  
  SELECT *
  FROM Music M
  WHERE (M.Genre = COALESCE(@Genre, M.Genre) OR
  M.Artist = COALESCE(@Artist, M.Artist))
  </code></pre>
  
  <p>This gives me the option to chose a genre and add a random artist that I would also like to see.</p>
  
  <p>But what if I want to pass in multiple Artists as a string,
  i.e. </p>
  
  <pre><code>@Genre = Rock
  @Artist = 'Eric Church, Bruno Mars'
  </code></pre>
  
  <p>where in essence I would need an IN statement but also have to handle instances where the variable is NULL?</p>
  
  <p>I am using SQL SERVER.</p>
  
  <p>Thank you</p>