Can i temporarily disable a foreign key constraint. How do i do this?
            Asked
            
        
        
            Active
            
        
            Viewed 1.8k times
        
    6
            
            
        - 
                    Check also this related question: [Can foreign key constraints be temporarily disabled using TSQL?](http://stackoverflow.com/questions/159038) – kristof Apr 08 '09 at 07:58
2 Answers
25
            To temporarily disable a constraint (foreign keys are constraints):
ALTER TABLE MyTable NOCHECK CONSTRAINT MyConstraint
To re-enable a constraint
ALTER TABLE MyTable CHECK CONSTRAINT MyConstraint
 
    
    
        Chris Shaffer
        
- 32,199
- 5
- 49
- 61
1
            
            
        Incidentally, this is why you need "Alter table" permissions when you BCP or Bulk Insert data into a table. Using the default configuration, check constraints and foreign keys are not checked.
 
    
    
        Andy Jones
        
- 1,472
- 9
- 15
 
    