How to Avoid Constraint SQL Server 2008 -
i have problem. got 2 tables, 1 foreign key.
table , table b
create table kdtrans int (5) primary key insert values (1),(2),(3)
then want insert in table b
create table b kdtrans int (5) primary key, foreign key kdtrans references a(kdtrans) insert b values (1),(2),(3),(4),(5)
these query error cause of constraint. should avoid constraint. wont insert new record in table a.
it possible disabling constraint might drop thing supposed guarantee no longer true.
to disable constraint can use
create table ( kdtrans int primary key ) insert values (1), (2), (3) create table b ( kdtrans int primary key constraint fk foreign key references a(kdtrans) ) alter table b nocheck constraint fk insert b values (1), (2), (3), (4), (5)
to drop use
alter table b drop constraint fk
Comments
Post a Comment