Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I 'DROP' and unamed relationship/constraint in MS Access with SQL?

I have a Microsoft Access database and I have two tables. Table1 has a primary key and Table2 has a foreign key that references Table1's primary key. This relationship is set up and viewable in the Relationship viewer in MS Access, the 'Enforce Referential Integrity' check box is checked, and the Join type is an inner join. The relationship is:

[Table1]--1---------N--[Table2]

I need to be able to 'DROP' this relationship/constraint via SQL. How do I do this? I have no name for this relationship/constraint as it was set up in Access manually, not with SQL. Is there a way to do what I need to do?

like image 261
Mike Webb Avatar asked Dec 16 '22 22:12

Mike Webb


1 Answers

Determine the relationship using

SELECT szRelationship FROM Msysrelationships WHERE szObject = 'childtablename' and szReferencedObject = 'parenttablename'

THEN

Use the ALTER TABLE command. Something along the line of this

ALTER TABLE Table2 DROP CONSTRAINT Relation1

like image 137
m0g Avatar answered Dec 26 '22 00:12

m0g