Return-Path: Delivered-To: apmail-db-ddlutils-dev-archive@www.apache.org Received: (qmail 90749 invoked from network); 3 Dec 2006 07:47:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Dec 2006 07:47:45 -0000 Received: (qmail 30287 invoked by uid 500); 3 Dec 2006 07:47:54 -0000 Delivered-To: apmail-db-ddlutils-dev-archive@db.apache.org Received: (qmail 30228 invoked by uid 500); 3 Dec 2006 07:47:53 -0000 Mailing-List: contact ddlutils-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ddlutils-dev@db.apache.org Delivered-To: mailing list ddlutils-dev@db.apache.org Received: (qmail 30216 invoked by uid 99); 3 Dec 2006 07:47:53 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Dec 2006 23:47:53 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Dec 2006 23:47:43 -0800 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 1D4DD7142FD for ; Sat, 2 Dec 2006 23:47:23 -0800 (PST) Message-ID: <25722502.1165132043117.JavaMail.jira@brutus> Date: Sat, 2 Dec 2006 23:47:23 -0800 (PST) From: "Thomas Dudziak (JIRA)" To: ddlutils-dev@db.apache.org Subject: [jira] Commented: (DDLUTILS-127) MsSqlBuilder does not drop foreign keys to a table before dropping the table. In-Reply-To: <29853541.1156941022483.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org [ http://issues.apache.org/jira/browse/DDLUTILS-127?page=3Dcomments#act= ion_12455153 ]=20 =20 Thomas Dudziak commented on DDLUTILS-127: ----------------------------------------- Could you please post the SQL in the database and the target model that you= used ? Also, please note that DdlUtils won't remove foreign keys automatically. It= will only do so if the foreign key is no longer in the target model (thoug= h it could certainly improved to generate an error before actually changing= the database). > MsSqlBuilder does not drop foreign keys to a table before dropping the ta= ble. > -------------------------------------------------------------------------= ---- > > Key: DDLUTILS-127 > URL: http://issues.apache.org/jira/browse/DDLUTILS-127 > Project: DdlUtils > Issue Type: Bug > Components: Core - SqlServer > Reporter: Christoffer Hammarstr=C3=B6m > Assigned To: Thomas Dudziak > Fix For: 1.0 > > Attachments: DDLUTILS-127.patch > > > Could not drop object 'Tmp_categories' because it is referenced by a FORE= IGN KEY constraint. Query: IF EXISTS (SELECT 1 FROM sysobjects WHERE type = =3D 'U' AND name =3D 'Tmp_categories') > BEGIN > DECLARE @tablename nvarchar(256), @constraintname nvarchar(256) > DECLARE refcursor CURSOR FOR > SELECT object_name(objs.parent_obj) tablename, objs.name constraintname > FROM sysobjects objs JOIN sysconstraints cons ON objs.id =3D cons.con= stid > WHERE objs.xtype !=3D 'PK' AND object_name(objs.parent_obj) =3D 'Tmp_= categories' OPEN refcursor > FETCH NEXT FROM refcursor INTO @tablename, @constraintname > WHILE @@FETCH_STATUS =3D 0 > BEGIN > EXEC ('ALTER TABLE '+@tablename+' DROP CONSTRAINT '+@constraintname= ) > FETCH NEXT FROM refcursor INTO @tablename, @constraintname > END > CLOSE refcursor > DEALLOCATE refcursor > DROP TABLE Tmp_categories > END; --=20 This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira