1首先删除所有的外检约束
--删除所有外键约束
DECLARE c1 cursor for
select 'alter table ['+ object_name(parent_obj) + '] drop constraint ['+name+']; 'from sysobjectswhere xtype = 'F'open c1declare @c1 varchar(8000)fetch next from c1 into @c1while(@@fetch_status=0)beginexec(@c1)fetch next from c1 into @c1endclose c1deallocate c1
2删除所有的表
DECLARE c2 cursor for
select 'drop table ['+name +']; 'from sysobjectswhere xtype = 'u'open c2declare @c2 varchar(8000)fetch next from c2 into @c2while(@@fetch_status=0)beginexec(@c2)fetch next from c2 into @c2endclose c2deallocate c2以前在oracle中经常遇到没法删掉数据库的问题(因为一个用户对应一个数据库),所以必须要删除表(要先删除外检约束),在重新生成, 今天在sql试了试,
成功了。