Why won't this SQL work?

Sharky Forums


Results 1 to 3 of 3

Thread: Why won't this SQL work?

  1. #1
    Goldfish
    Join Date
    Jul 2001
    Location
    Baltimore, MD USA
    Posts
    90

    Post 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

  2. #2
    Ursus Arctos Moderatis Grizzly's Avatar
    Join Date
    Sep 2000
    Location
    Providence, RI USA
    Posts
    3,077

    Post

    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.

  3. #3
    Goldfish
    Join Date
    Jul 2001
    Location
    Baltimore, MD USA
    Posts
    90

    Post

    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;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •