-
Why won't this SQL work?
Hey guys,
I am trying to build a database in SQLServer 7 using a sqlscript a friend sent me. I open up the query analyzer and run the script, but I get errors on all of his foreign key assignments. He told me that the SQL is standard, and that the script loaded up fine in sybase... What gives? I know squat about SQL, so if you could shed some light...
here's one of the lines that returns a syntax error:
ALTER TABLE MemberAddress
ADD FOREIGN KEY fk_MemberAddress (MemberObjid)
REFERENCES Member (Objid) on update cascade on delete cascade;
thanks,
tim
-
The part that's throwing the sytax error is the "on update cascade on delete cascade."
Cascading is more of an Oracle feature, which SQL 7 doesn't support. You can write some custom Triggers to similate the Cascade functionality, but it's definitely a pain in the arse.
-
Thanks! The working statment is this:
(I had to remove the fk_MemberAddress line, too)
ALTER TABLE MemberAddress
ADD FOREIGN KEY (MemberObjid)
REFERENCES Member (Objid) NOT FOR REPLICATION;