SQLserver删除某数据库中所有表实现思路

worldwind87924 18 0 PDF 2020-12-17 02:12:16

方便删除数据库中所有的数据表,清空数据库,有些有约束,不能直接delete,需要先删除库中的约束,代码如下 代码如下: –删除所有约束 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 nextfrom c1 into@c1 while(@@fetch_status=0) begin exec(@

用户评论
请输入评论内容
评分:
暂无评论