Your wanting to create these foreign key constraits without checking the current keys in the table against their primary keys? If so, you need to use the WITH NOCHECK flag. However this is _not_ a recommend practice. If you later do an update to one of those rows, the constrait will fire and the update will fail.
 
- Daniel Elmore
 
 

 -----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Brent Helms
Sent: Friday, April 29, 2005 3:00 PM
To: [email protected]
Subject: Transact SQL Question

I am having a tough time finding out how to manually write out the TSQL to generate a junction table that contains the following integrity constraint: "Check Existing Data On Connection". 

This is what I have so far:

CREATE TABLE sec_ApplicationModuleAccess
(
 ApplicationID INT NOT NULL,
 ApplicationModuleID INT NOT NULL
 CONSTRAINT sec_ApplicationModuleAccess_fk FOREIGN KEY (ApplicationID)
 REFERENCES sec_Applications (ApplicationID),
 CONSTRAINT sec_ApplicationModuleAccess_fk2 FOREIGN KEY (ApplicationModuleID)
 REFERENCES sec_ApplicationModules (ApplicationModuleID),
 CONSTRAINT sec_ApplicationModuleAccess_pk PRIMARY KEY CLUSTERED(ApplicationID,ApplicationModuleID)
)

The problem is: It does not set "Check Existing Data On Connection" to true (or checked).  It does set "enforce relationship for replication, inserts, and updates to true. 

Any ideas what the missing link is?

Regards,

Brent Helms
Carlot.com

Reply via email to