declare @dropSQL nvarchar(max)
set @dropSQL=N''
select distinct @dropSQL=@dropSQL+'ALTER TABLE dbo.'+table_name+' DROP CONSTRAINT '+constraint_name+';'
from INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE
EXEC dbo.sp_executesql @dropSQL
GO
declare @dropSQL nvarchar(max)
set @dropSQL=N''
select distinct @dropSQL=@dropSQL+'DROP INDEX '+name+' ON dbo.'+object_name(object_id)+';'
from sys.indexes
where name is not null and object_name(object_id)
in (select distinct table_name from LIVEDB.information_schema.columns
)
EXEC dbo.sp_executesql @dropSQL