xxxxxxxxxx
-- Disable the foreign key constraint
ALTER TABLE YourTableName NOCHECK CONSTRAINT YourForeignKeyConstraintName;
-- Perform your insert operation here
INSERT INTO YourTableName (Column1, Column2) VALUES ('Value1', 'Value2');
-- Enable the foreign key constraint
ALTER TABLE YourTableName WITH CHECK CHECK CONSTRAINT YourForeignKeyConstraintName;
xxxxxxxxxx
-- Disable the foreign key constraint
ALTER TABLE [YourTableName]
NOCHECK CONSTRAINT [YourForeignKeyConstraintName]
-- Perform the ALTER TABLE operation (replace with your actual ALTER TABLE statement)
ALTER TABLE [YourTableName]
-- Add your ALTER TABLE statement here
-- Re-enable the foreign key constraint
ALTER TABLE [YourTableName]
CHECK CONSTRAINT [YourForeignKeyConstraintName]
xxxxxxxxxx
SELECT *
FROM [rpt].ReportLessonCompetency rlc
WHERE NOT EXISTS
(
SELECT 1
FROM [rpt].TraineeGrade tg
WHERE tg.Id = rlc.Grade
)