title: Drop Multiple Indexes If Exist In One Drop Statement
body: <p>I would like to write one drop statement to drop indexes, but I also want to use an IF EXISTS check.</p>
  
  <p>Syntax From <a href="https://msdn.microsoft.com/en-us/library/ms176118.aspx" rel="nofollow">MSDN</a>:</p>
  
  <pre><code>DROP INDEX [ IF EXISTS ] 
  { &lt;drop_relational_or_xml_or_spatial_index&gt; [ ,...n ] 
  | &lt;drop_backward_compatible_index&gt; [ ,...n ]
  }
  </code></pre>
  
  <p>I am trying to run this drop statement but the syntax near IF EXISTS is incorrect according to SQL Server.</p>
  
  <pre><code>DROP INDEX IF EXISTS idx1 on table1,
  idx2 on table2,
  idx3 on table2
  </code></pre>
  
  <p>I am aware that I can use multiple statements, like below, but I much prefer the single DROP statement as shown on MSDN.</p>
  
  <pre><code>IF EXISTS (SELECT * FROM sys.indexes WHERE name = 'idx1')
  BEGIN
      DROP INDEX idx1 ON table1
  END
  </code></pre>
  
  <p>Why am I getting the syntax error when I follow the syntax shown on MSDN?</p>