title: How to check if I can remove index from DB in SQL Server
body: <p>After large redesigning of DB I need to remove all indices from it, and set new indices.<br>
  I found good scrpipt to get all indices and remove but I have problem - I cannot remove indices created by PRIMARY KEY constraint. (maybe there are also other kind of indices that I cannot remove).</p>
  
  <p>My question is: how to change code below to remove all indices except indices created for primary keys or other that I cannot remove manually.</p>
  
  <pre><code>DECLARE @indexName VARCHAR(128)
  DECLARE @tableName VARCHAR(128)
  
  DECLARE [indexes] CURSOR FOR
      SELECT  [sysindexes].[name] AS [Index], [sysobjects].[name] AS [Table]
      FROM [sysindexes]
      INNER JOIN [sysobjects] ON [sysindexes].[id] = [sysobjects].[id]    
      WHERE [sysindexes].[name] IS NOT NULL AND [sysobjects].[type] = 'U'
  
  OPEN [indexes]
  
  FETCH NEXT FROM [indexes] INTO @indexName, @tableName
  WHILE @@FETCH_STATUS = 0
  BEGIN
      EXEC ('DROP INDEX [' + @indexName + '] ON [' + @tableName + ']')
      FETCH NEXT FROM [indexes] INTO @indexName, @tableName
  END
  
  CLOSE [indexes]
  DEALLOCATE [indexes]
  </code></pre>