• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

How to delete all the indexes in a DB in single shot?

How to delete all the indexes in a DB using TSQL query?

Please do assist.
0
Easwaran Paramasivam
Asked:
Easwaran Paramasivam
  • 2
1 Solution
 
Easwaran ParamasivamAuthor Commented:
declare @qry nvarchar(max);
select @qry =
(SELECT  'DROP INDEX ' + ix.name + ' ON ' + OBJECT_NAME(ID) + '; '
FROM  sysindexes ix
WHERE   ix.Name IS NOT null and ix.Name like '%prefix_%'
for xml path(''));
exec sp_executesql @qry  

Above code did the trick.
0
 
Easwaran ParamasivamAuthor Commented:
Accpting answer for tracking purpose
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now