Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-05-30
2
Medium Priority
?
258 Views
Last Modified: 2013-05-30
How to delete all the indexes in a DB using TSQL query?

Please do assist.
0
Comment
Question by:Easwaran Paramasivam
  • 2
2 Comments
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 0 total points
ID: 39207169
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
 
LVL 16

Author Closing Comment

by:Easwaran Paramasivam
ID: 39207178
Accpting answer for tracking purpose
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question