A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Deleting a foreign key relationship in SQL



 
 
Thread Tools Display Modes
  #1  
Old December 21st, 2004, 05:32 PM
Stevio
external usenet poster
 
Posts: n/a
Default Deleting a foreign key relationship in SQL

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


  #2  
Old December 21st, 2004, 06:14 PM
Roger Carlson
external usenet poster
 
Posts: n/a
Default

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 su
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/...UBED1=ACCESS-L




"Stevio" wrote in message
...
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




  #3  
Old December 22nd, 2004, 02:51 PM
Stevio
external usenet poster
 
Posts: n/a
Default

Thanks Roger, I got it working thanks to your advice!

Stephen

"Roger Carlson" wrote in message
...
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 su
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/...UBED1=ACCESS-L

"Stevio" wrote in message
...
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



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Table Wizard Does Not Set Relationship if Foreign Key and Primary Key Name Do Not Match Exactly in Case. HDW Database Design 3 October 16th, 2004 03:42 AM
Function isn't available in expressions in query expression Reiner Harmgardt General Discussion 4 July 21st, 2004 09:30 AM


All times are GMT +1. The time now is 04:28 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.