Re: Help with Delete query
From: Tibor Karaszi (tibor_please.no.email_karaszi_at_hotmail.nomail.com)
Date: 08/30/04
- Next message: Mohan: "Re: query"
- Previous message: Janak Joshi: "Re: Identifying Integers & Alphabets"
- In reply to: Diego F.: "Re: Help with Delete query"
- Next in thread: Diego F.: "Re: Help with Delete query"
- Reply: Diego F.: "Re: Help with Delete query"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 30 Aug 2004 18:16:09 +0200
So as I understand it, you want to have orders for which the customer doesn't exist. then you should not have
created the foreign key between the tables in the first pace, as this is exactly what the foreign key is there
to prevent.
You can create a "dummy" customer and update the order so they refer to that dummy customer. Or disable the
foreign key and delete the customer.
Or delete the foreign key if you don't want it to do the job it is designed to do. :-)
-- Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ "Diego F." <diegofrNO@terra.es> wrote in message news:%23eIDfRpjEHA.3696@TK2MSFTNGP15.phx.gbl... > Yes, is what you say. I want to delete the customer, but mantain the entries > in the orders table. > > -- > > Saludos, > > Diego F. > > > "Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> escribió > en el mensaje news:OtVZjwojEHA.536@TK2MSFTNGP11.phx.gbl... > > So, as an example, your Orders table has a foreign key to the Customers > table. And you want to > > delete a customer. This is what foreign key are there for. Or are you > saying that it is the > > opposite. Try to describe your problems using the terms "referencing" and > "referenced" table. Makes > > it easier to understand. In my example, Orders is the referencing table, > and Customers is the > > Referenced table. Or, if it is easier for you, you could post (simplified) > DDL. > > > > -- > > Tibor Karaszi, SQL Server MVP > > http://www.karaszi.com/sqlserver/default.asp > > http://www.solidqualitylearning.com/ > > > > > > "Diego F." <diegofrNO@terra.es> wrote in message > news:eNp8ZpojEHA.384@TK2MSFTNGP10.phx.gbl... > > > Hi. I'm trying to build the delete query from a database. > > > > > > The problem is that the item I try to delete has a column that is the > > > foreign key of another table and it doesn't allow me to do that. Why > not? > > > > > > I don't want to delete the items from the other table where it's the > foreing > > > key. > > > > > > Regards, > > > > > > Diego F. > > > > > > > > > > > >
- Next message: Mohan: "Re: query"
- Previous message: Janak Joshi: "Re: Identifying Integers & Alphabets"
- In reply to: Diego F.: "Re: Help with Delete query"
- Next in thread: Diego F.: "Re: Help with Delete query"
- Reply: Diego F.: "Re: Help with Delete query"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|