ALTER TABLE [dbo].[Enrollment] ADD
CONSTRAINT [ClassStudentMap2Enrollment] FOREIGN KEY
REFERENCES [dbo].[ClassStudentMap] (
ON DELETE CASCADE
Server: Msg 547, Level 16, State 1, Line 1
ALTER TABLE statement conflicted with COLUMN FOREIGN KEY constraint 'ClassStudentMap2Enrollment'. The conflict occurred in database 'Schoolwise', table 'ClassStudentMap', column 'CSMid'.
What's going on here? My brain is on strike. I dropped this table, created it again using a SELECT INTO from tmp_Enrollment and tried to recreate the constraints, indexes etc from a backup script of Enrollment. Everything went well apart from the above code.