-----------------
ALTER TABLE ccietlfindev.finsilver.companyperiods ALTER COLUMN iCompanyId SET NOT NULL;
ALTER TABLE ccietlfindev.finsilver.companyperiods ALTER COLUMN iPeriodId SET NOT NULL
ALTER TABLE ccietlfindev.finsilver.companyperiods ADD CONSTRAINT companyperiods_pk PRIMARY KEY(iCompanyId,iPeriodId);
select iCompanyId,iPeriodId, count(1) from ccietlfindev.finsilver.companyperiods
group by iCompanyId,iPeriodId
having count(1) > 1
insert into table ccietlfindev.finsilver.companyperiods
values ('1','182','1996-08-31 23:59:59.998','Aug 1998','1996-08-31 00:00:00.000','C','2023-05-11 15:01:43.707')
Select * from ccietlfindev.finsilver.companyperiods
where iCompanyId = '1' and iPeriodId='182'
delete from ccietlfindev.finsilver.companyperiods
where iCompanyId = '1' and iPeriodId='182' and PeriodDesc='Aug 1997'
Select * from companyperiods
In the case when I run count after the second record insert, I see 2 records instead of just one and should have failed saying "you are trying to insert duplicate records where there is a primary key setup"
@Debayan Mukherjeeโ