Article ID: 128877
Article Last Modified on 7/24/1999
' Prevent inserts if no matching key in 'Categories'.
IF (SELECT COUNT(*) FROM inserted) !=
(SELECT COUNT(*) FROM Categories, inserted WHERE _
(Categories.Category_ID = inserted.Category_ID))
BEGIN
RAISERROR 44447 "Cannot add or change record._
Referential integrity rules require a related record in_
table 'Categories'."
ROLLBACK TRANSACTION
END
to read:
' Prevent inserts if no matching key in 'Categories'.
IF (SELECT Category_ID FROM inserted) IS NOT NULL
IF (SELECT COUNT(*) FROM inserted) !=
(SELECT COUNT(*) FROM Categories, inserted WHERE _
(Categories.Category_ID = inserted.Category_ID))
BEGIN
RAISERROR 44447 "Cannot add or change record._
Referential integrity rules require a related record in_
table 'Categories'."
ROLLBACK TRANSACTION
END
NOTE: In the sample code above, an underscore (_) is used as a line-
continuation character. Remove the underscore from the end of the line
when re-creating this code.
Keywords: kberrmsg kbbug KB128877