Alter Table statment: adding foreign key WITHOUT referential integrity
Question posted by: moskie@gmail.com
(Guest)
on
July 12th, 2006 11:35 PM
Is there a way to run an alter table statement that adds a constraint
for a foreign key, but does *not* check the existing data for
refrential integrity? I'm essentially looking for the equivalent to SQL
Server's NOCHECK flag.
I am able to create equivalent keys in the Relationships screen, as
long as the "Enforce referential integrity" box is left unchecked. But
when I try to create that relationship with an ALTER TABLE statement, I
always get an error like:
"Cannot create relationships to enforce referential integrity.
Existing data in table 'tblSubcontracts' violates referential integrity
rules in table 'tbl_AgmtFormat'."
Is there a clause I can add to my ALTER TABLE statement to get around
this?
Thanks,
Moskie
3
Answers Posted
I should add I'm using MS Access 2003.
mos...@gmail.com wrote:
Quote:
Originally Posted by
Is there a way to run an alter table statement that adds a constraint
for a foreign key, but does *not* check the existing data for
refrential integrity? I'm essentially looking for the equivalent to SQL
Server's NOCHECK flag.
>
I am able to create equivalent keys in the Relationships screen, as
long as the "Enforce referential integrity" box is left unchecked. But
when I try to create that relationship with an ALTER TABLE statement, I
always get an error like:
>
"Cannot create relationships to enforce referential integrity.
Existing data in table 'tblSubcontracts' violates referential integrity
rules in table 'tbl_AgmtFormat'."
>
Is there a clause I can add to my ALTER TABLE statement to get around
this?
>
Thanks,
Moskie
Join Bytes! wrote:
Quote:
Originally Posted by
Is there a way to run an alter table statement that adds a constraint
for a foreign key, but does *not* check the existing data for
refrential integrity? I'm essentially looking for the equivalent to SQL
Server's NOCHECK flag.
>
I am able to create equivalent keys in the Relationships screen, as
long as the "Enforce referential integrity" box is left unchecked. But
when I try to create that relationship with an ALTER TABLE statement, I
always get an error like:
>
"Cannot create relationships to enforce referential integrity.
Existing data in table 'tblSubcontracts' violates referential integrity
rules in table 'tbl_AgmtFormat'."
I don't know of any. If I needed to do this I would try FOREIGN KEY NO
INDEX. I am !!!!!!guessing!!!!! that if there is no Index JET may not
have any way of checking existing data. I am also guessing this has 5%
chance of being successful.
On 12 Jul 2006 15:37:26 -0700, Join Bytes! wrote:
Add a new Relation object using DAO. The help file has details.
You know that an unenforced relation has no real value, right?
-Tom.
Quote:
Originally Posted by
>Is there a way to run an alter table statement that adds a constraint
>for a foreign key, but does *not* check the existing data for
>refrential integrity? I'm essentially looking for the equivalent to SQL
>Server's NOCHECK flag.
>
>I am able to create equivalent keys in the Relationships screen, as
>long as the "Enforce referential integrity" box is left unchecked. But
>when I try to create that relationship with an ALTER TABLE statement, I
>always get an error like:
>
>"Cannot create relationships to enforce referential integrity.
>Existing data in table 'tblSubcontracts' violates referential integrity
>rules in table 'tbl_AgmtFormat'."
>
>Is there a clause I can add to my ALTER TABLE statement to get around
>this?
>
>Thanks,
>Moskie
|
|
|
What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 197,027 network members.
Top Community Contributors
|