如何在SQL Server 2008数据库中删除索引?以下是我所拥有的内容:
declare @procname varchar(500)
declare cur cursor
for
select name from sysindexes
open cur
fetch next from cur into @procname
while @@FETCH_STATUS=0
begin
exec ('drop index ' + @procname)
fetch next from cur into @procname
end
close cur
deallocate cur
EXEC sp_executesql @dropstatement
,而不是EXEC sp_execute
。此外,最好将模式包含在表名中,并使用QUOTENAME
确保命名不良的对象不会导致错误。 - GarethD