Wrox Programmer Forums
|
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 20th, 2007, 01:39 AM
Friend of Wrox
 
Join Date: Aug 2006
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Default primary key contraint

my member master table have a field called memberID which is referenced key to many tables. when i try to delete a record from membermaster table it shows error of reference key.
i want to know command or option which can be added in the table to ignore the reference key for deletion.



thanks......
__________________
thanks......
 
Old September 26th, 2007, 01:38 PM
SQLScott's Avatar
Wrox Author
 
Join Date: Dec 2004
Posts: 338
Thanks: 0
Thanked 2 Times in 2 Posts
Default

You can't. This is what relational data is all about. If you deleted the member master record, you would then have records in related tables that reference a value that no longer exists.

Well, i said you can't, but if you make some changes you can. You can change the relationship to include CASCADE DELETE (you'll have to drop and recreate the relationship between the member master table and the other related tables). This will let you delete the record from the member master table, but then it will also delete all reldated records in referened tables.

You can do that, or, you can remove the relationships all togehter (I WOULD NOT RECOMMEND THIS).

Again, this is what relational databases is all about. Keep the integrity of the data clean.

Hope this helps...

Scott Klein
Author - Professional SQL Server 2005 XML
http://www.wrox.com/WileyCDA/WroxTit...764597922.html





Similar Threads
Thread Thread Starter Forum Replies Last Post
Foreign key not updating with Primary key xavier1945 BOOK: Access 2003 VBA Programmer's Reference 2 July 4th, 2007 09:48 PM
Primary key cf2006 BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 1 July 31st, 2006 07:21 PM
FOREIGN KEY and PRIMARY KEY Constraints junemo Oracle 10 June 15th, 2004 01:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.