SELECT
CASE
WHEN (is_primary_key =1 or is_unique = 1)
THEN 'ALTER TABLE ['+SCHEMA_NAME(o.uid)+'].['+o.name+'] DROP CONSTRAINT ['+i.name+']'
ELSE 'DROP INDEX [' +i.name +'] ON ['+schema_name(o.uid)+'].['+i.name+']'
END
FROM sys.indexes i join sysobjects o
ON i.object_id=o.id and i.object_id>99 and i.type_desc<>'HEAP' and o.type ='U'
|