Vous êtes ici :
Cette requête génère les scripts de création et suppression des contraintes CHECK dans la base de données courante.
Transact-SQL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
/*------------------------------------------------------------------- [SCRIPT] Generate Check Constraints Scripts.sql [DATABASE] current [DESCRIPTION] Generate Check Constraints operations script [MAJ PAR] DATAFLY - Arian Papillon -------------------------------------------------------------------*/ SELECT 'ALTER TABLE [' + SCHEMA_NAME(st.schema_id) + '].[' + st.name + '] WITH NOCHECK ' + 'ADD CONSTRAINT ' + scc.name + ' CHECK ' + scc.definition AS '--Create Check Constraints' , 'ALTER TABLE [' + SCHEMA_NAME(st.schema_id) + '].[' + st.name + '] DROP CONSTRAINT ' + scc.name AS '--Drop Check Constraints' FROM sys.tables st JOIN sys.check_constraints scc ON st.object_id = scc.parent_object_id ORDER BY st.name; |
Table of Contents