Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
IGNORING FOREIGN KEYS
Message
 
À
05/12/2000 16:07:03
Greg Coopman
Gc Systems Corporation
Hollywood, Floride, États-Unis
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00449631
Message ID:
00449637
Vues:
12
>I am writing a script to place initialized rows into a database that has be completed as far as the creation of all my foreign key (FK)relationships are concerned. Unfortunately some of the initial table rows will not be able to be entered unless I take certain FKs out, then place the data in, then reset the FKs to the tables again. Is there a way in that I can have the program disregard the Foreign Keys (without dropping and re-creating the tables without the foreign keys) so that I can get the rows in I need, and then easily turn on the referential integrity again. Once the rows are in the integrity will be o.k.

In your script, can you not:

1. Drop the FK constraint
2. Import the data
3. Recreate the FK constraint

With something like this:

IF OBJECT_ID('dbo.FK_ImportTypeID') IS NOT NULL
ALTER TABLE Import
DROP CONSTRAINT FK_ImportTypeID

/*
Data import routine here
/*

ALTER TABLE Import
ADD CONSTRAINT FK_ImportTypeID FOREIGN KEY (ImportTypeID) REFERENCES ImportType(ImportTypeID)
Chris McCandless
Red Sky Software
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform