--drop table dbo.TestDisableFK_Pk
--drop table dbo.TestDisableFK_Fk
create table dbo.TestDisableFK_Pk
(
PKId int not null,
PkStr nvarchar(50) null,
CONSTRAINT [PK_Pk] PRIMARY KEY CLUSTERED
(
PKId ASC
)
)
create table dbo.TestDisableFK_Fk
(
FKId int not null,
PKId int not null,
PkStr nvarchar(50) null
)
ALTER TABLE dbo.TestDisableFK_Fk WITH CHECK ADD CONSTRAINT [FK_Fk] FOREIGN KEY(PKId)
REFERENCES dbo.TestDisableFK_Pk (PKId)
insert into dbo.TestDisableFK_Pk (PKId) values (1), (2), (3)
insert into dbo.TestDisableFK_Fk (FKId, PKId) values (1, 1), (2, 2), (3, 3)
select * from dbo.TestDisableFK_Pk
select * from dbo.TestDisableFK_Fk
update dbo.TestDisableFK_Fk set PKId = 4 where FKId = 1
delete dbo.TestDisableFK_Pk where PKId = 1
ALTER TABLE dbo.TestDisableFK_Fk NOCHECK CONSTRAINT [FK_Fk]
update dbo.TestDisableFK_Fk set PKId = 4 where FKId = 1
select * from dbo.TestDisableFK_Pk
select * from dbo.TestDisableFK_Fk
ALTER TABLE dbo.TestDisableFK_Fk WITH CHECK CHECK CONSTRAINT [FK_Fk]
update dbo.TestDisableFK_Pk set PKId = 4 where PKId = 1
ALTER TABLE dbo.TestDisableFK_Fk WITH CHECK CHECK CONSTRAINT [FK_Fk]
select * from dbo.TestDisableFK_Pk
select * from dbo.TestDisableFK_Fk