DECLARE c1 cursor for
select 'alter table ['+ object_name(parent_obj) + '] drop constraint ['+name+']; '
from sysobjects
where xtype = 'F'
open c1
declare @c1 varchar(8000)
fetch next from c1 into @c1
while(@@fetch_status=0)
begin
exec(@c1)
fetch next from c1 into @c1
end
close c1
deallocate c1
--删除表
DECLARE c2 cursor for
select 'drop table ['+name +']; '
from sysobjects
where xtype = 'u'
open c2
declare @c2 varchar(8000)
fetch next from c2 into @c2
while(@@fetch_status=0)
begin
exec(@c2)
fetch next from c2 into @c2
end
close c2
deallocate c2
--所有存储过程
DECLARE c3 cursor for
select 'drop procedure['+name +']; '
from sysobjects
where xtype = 'p'
open c3
declare @c3 varchar(8000)
fetch next from c3 into @c3
while(@@fetch_status=0)
begin
exec(@c3)
fetch next from c3 into @c3
end
close c3
deallocate c3