Deleting a foreign key relationship in SQL

S

Stevio

How do you delete or drop a foreign key relationship from an Access
database, using SQL, when the foreign key relationship was created within
Access so I do not know/have the name of the relationship?

I have found the SQL to do this but you need the name of the foreign key
relationship, which I don't have!

ALTER TABLE Table2 DROP CONSTRAINT Relation1

How can I find out the name, or how can I delete the relationship without
the name?

Thanks,
Stephen
 
R

Roger Carlson

It will usually be the name of the primary table concatenated with the
foreign table:
Table1Table2

But here's how you can find out for sure:
1) Go to Tools > Options from the Database Window
2) Click the System Objects checkbox in the View tab. You will now see the
system tables
3) Look for a table called MSysRelationships and open it
4) The field called szRelationship holds the name
5) After you are done, uncheck the System Objects checkbox

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top