Problem solve Get help with specific problems with your technologies, process and projects.

NOCHECK all constraints

This script performs a solution to NOCHECK all constraints in a MS SQL Server 7.0 database.

This script performs a solution to NOCHECK all constraints in a MS SQL Server 7.0 database:

DECLARE
@tableid INTEGER,
@tablename VARCHAR(60),
@fkid INTEGER,
@fkname VARCHAR(200),
@tableuser VARCHAR(3),
@chaine VARCHAR(100),
@compteur INTEGER,
@compteur2 INTEGER
-- Temporary suppression of constraints FK

DECLARE tablecursor CURSOR FOR 
SELECT name FROM sysobjects where xtype = 'U';

OPEN tablecursor


FETCH NEXT FROM tablecursor INTO @fkname
WHILE @@FETCH_STATUS = 0
BEGIN
	PRINT ('Temporary suppression of constraints of table ' + @fkname)
	EXEC ('ALTER TABLE ' + @fkname + ' NOCHECK CONSTRAINT ALL')
	FETCH NEXT FROM tablecursor INTO @fkname
END

CLOSE tablecursor
DEALLOCATE tablecursor

For More Information


This was last published in May 2001

Dig Deeper on SQL Server Database Modeling and Design

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchBusinessAnalytics

SearchDataCenter

SearchDataManagement

SearchAWS

SearchOracle

SearchContentManagement

SearchWindowsServer

Close