Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Unable To Create Relationship Error - Why ?? Expand / Collapse
Author
Message
Posted Sunday, February 6, 2005 2:29 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, September 30, 2005 2:06 PM
Points: 24, Visits: 1

ALTER TABLE [dbo].[Enrollment] ADD
 CONSTRAINT [ClassStudentMap2Enrollment] FOREIGN KEY
 (
  [CSMid]
  REFERENCES [dbo].[ClassStudentMap] (
  [CSMid]
  ON DELETE CASCADE
GO

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.

Thanks.

Post #159911
Posted Sunday, February 6, 2005 2:33 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 2:45 AM
Points: 21,397, Visits: 9,610
Have you checked for invalid data that may make the foreign key fail (maybe some data has been deleted in the parent table in between data transfers)?
Post #159912
Posted Sunday, February 6, 2005 2:39 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, September 30, 2005 2:06 PM
Points: 24, Visits: 1

You little beauty - that was it - my brain was on strike

Thanks for the speedy reply - very much appreciated indeed.

 

Regards.

Post #159914
Posted Sunday, February 6, 2005 3:36 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 2:45 AM
Points: 21,397, Visits: 9,610
I wouldn't go as far as say little, but I'll take the beauty part of the compliment .

HTH.
Post #159917
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse