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.
LVL 16
Easwaran ParamasivamAsked:
Who is Participating?
 
Easwaran ParamasivamConnect With a Mentor Author 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
All Courses

From novice to tech pro — start learning today.