August 5, 2012 at 3:41 am
Want to update t4 table
but update fails as there is relationship between tables. Right there is one to many relationship between T3 and T4
CREATE TABLE T3
(
FirstName NVARCHAR(255),
MiddleName NVARCHAR(255),
LastName NVARCHAR(255),
ContactID INT,
CONSTRAINT pk_T3_pid PRIMARY KEY(ContactID)
)
GO
CREATE TABLE T4
(
ContactID INT,
SalesOrderID INT,
TotalDue MONEY,
CONSTRAINT pk_T4_sid PRIMARY KEY(SalesOrderID),
CONSTRAINT fk_T4_sid FOREIGN KEY(ContactID) REFERENCES T3(ContactID)
)
GO
I want to update T4 table for ContactID= 1 where i want to update SalesOrderID and TotalDue
How to go ahead with this kind of update
August 5, 2012 at 7:32 am
You may disable constraint like that
alter table dbo.T4 nocheck constraint fk_T4_sid
and do what you want, but, be aware of performance problems. I blogged about it here[/url] (unfortunatelly it is only in russian, but t-sql and plans talk for them selfes).
To have all the benefits of FK, your FK should be trusted, that means, that there should be a solid integrity of data and no missing values of fk column for pk.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply