恢复和去掉所有表约束
2014-03-19 19:42
211 查看
--去掉所有表约束 declare @n nvarchar(max) declare allTable cursor for select name from sys.tables open allTable fetch next from allTable into @n while @@fetch_status = 0 begin exec ('ALTER TABLE '+@n+' NOCHECK CONSTRAInT ALL') exec ('ALTER TABLE '+@n+' DISABLE TRIGGER ALL') print('已经去掉表'+@n+'的约束') fetch next from allTable into @n end close allTable deallocate allTable
--恢复所有表的约束 declare @n nvarchar(max) declare allTable cursor for select name from sys.tables open allTable fetch next from allTable into @n while @@fetch_status = 0 begin exec ('ALTER TABLE '+@n+' CHECK CONSTRAInT ALL') exec ('ALTER TABLE '+@n+' enABLE TRIGGER ALL') print('已经恢复表'+@n+'的约束') fetch next from allTable into @n end close allTable deallocate allTable
相关文章推荐
- eclipse去掉所有断点 恢复到默认窗口
- SQL Server 临时禁用和启用所有外键约束
- Leetcode: restore ipAddress 恢复ip地址,找出所有可能性
- 如何去掉C#字符串中的所有空格
- 按命名规范重命名所有默认值约束名称
- sql server所有表的所有者恢复为dbo
- 去掉内容中的所有全部html标签。
- 去掉echsop头部和底部的所有的版权
- 采用递归去掉string里面的所有空格
- Win7中去掉默认打开文件的关联程序,恢复成未知应用程序
- DBCC大全集之(适用版本MS SQLServer 2008 R2)----DBCC CHECKCONSTRAINTS检查当前数据库中指定表上的指定约束或所有约束的完整性
- devExpress grid:父级grid与子grid关联时可能会出现错误:不能启用此约束,因为不是所有的值都具有相应的父值。
- 常用脚本--Word文档中去掉所有超链接
- 去掉淘宝导航栏的所有分类
- sql 恢复指定文件夹下的所有日志文件。
- 对于一般的数组类型,简单使用TYPE_MAIN_VARIANT无法将所有的qualifiers去掉?
- SQLserver 删除数据所有表和存储过程和约束
- 不能启用此约束,因为不是所有的值都具有相应的父值的解决方法
- android去掉系统状态栏(StatusBar),让所有app程序均是全屏显示