IF EXISTS(SELECT Name FROM Sysobjects WHERE Name = 'PK_tblExclusiveInsuranceCode')
Begin

ALTER TABLE dbo.ExclusiveInsuranceCode DROP CONSTRAINT PK_tblExclusiveInsuranceCode;

ALTER TABLE dbo.ExclusiveInsuranceCode ALTER COLUMN GoodsCode VARCHAR(15) NOT NULL;

ALTER TABLE dbo.ExclusiveInsuranceCode   ADD CONSTRAINT PK_ExclusiveInsuranceCodeId PRIMARY KEY CLUSTERED (ID);

ALTER TABLE ExclusiveInsuranceCode ADD CONSTRAINT conExclusiveInsuranceCode UNIQUE (Code , GoodsCode , InsuranceCode);

DELETE FROM dbo.ExclusiveInsuranceCode WHERE GoodsCode NOT IN ( SELECT K_Code FROM dbo.KalaId ) ;

ALTER TABLE dbo.ExclusiveInsuranceCode ADD CONSTRAINT FK_ExclusiveInsuranceCode_KalaId FOREIGN KEY(GoodsCode) REFERENCES dbo.KalaId(K_Code) ON UPDATE  CASCADE ON DELETE  CASCADE 
End