X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5C6BE564E0 for ; Mon, 28 Feb 2005 06:07:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 67392-06 for ; Mon, 28 Feb 2005 06:07:29 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id B1B035649A for ; Mon, 28 Feb 2005 06:07:29 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.13.1/8.13.1) with ESMTP id j1S67RQm068381 for ; Mon, 28 Feb 2005 06:07:27 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.13.1/8.13.1/Submit) id j1S5gnDv062146 for pgsql-sql@postgresql.org; Mon, 28 Feb 2005 05:42:49 GMT (envelope-from news) From: "Igor Kryltsov" X-Newsgroups: pgsql.sql Subject: Postgresql FK to MS SQL triggers Date: Mon, 28 Feb 2005 16:46:55 +1100 Organization: Hub.Org Networking Services Lines: 34 Message-ID: X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.746 tagged_above=0 required=5 tests=ALL_TRUSTED, FORGED_YAHOO_RCVD, PRIORITY_NO_NAME, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200503/11 X-Sequence-Number: 20489 Hi, If you are moving from Postgres to MS SQL you will most likely will find that you can not recreate your PostgreSQL FK to MSSQL FK because this enterprise class database will NOT allow you to create all 3 FK which are exist in your PGSQL: table users(user_id PK) table journal(created_by, modified_by, deleted_by) ADD CONSTRAINT fk_created_by FOREIGN KEY (created_by) REFERENCES users(user_id) MATCH FULL ON UPDATE CASCADE ON DELETE CASCADE; ADD CONSTRAINT fk_modified_by FOREIGN KEY (modified_by) REFERENCES users(user_id) MATCH FULL ON UPDATE CASCADE ON DELETE CASCADE; ADD CONSTRAINT fk_deleted_by FOREIGN KEY (deleted_by) REFERENCES users(user_id) MATCH FULL ON UPDATE CASCADE ON DELETE CASCADE; For interested people I wrote a PHP script which: 1) Extracts all underlying triggers from pg_trigger table in Postgres used to support FK (3 triggers for each FK) 2) Generates a MSSQL script file which recreates all triggers in MSSQL Hope it will save some time for somebody. Igor