I have a check constraint on a table in my DB. My understanding of a check is it sets a logical condition that must be true for records in a table.
USE [myDB]
GO
ALTER TABLE [dbo].[myTable] WITH CHECK ADD CONSTRAINT [oneProgramPerTest] CHECK (([dbo].[howManyProgPerTest]([TestId])<(2)))
GO
ALTER TABLE [dbo].[myTable] CHECK CONSTRAINT [oneProgramPerTest]
GO
But I am able to do an update to the table that breaks the constraint. After the update, this query returns 9 records:
select COUNT (*) from myDB.dbo.myTable where myDB.[dbo].[howManyProgPerTest](testID)>1
What might be going on?