Uploaded image for project: 'DdlUtils'
  1. DdlUtils
  2. DDLUTILS-109

MSSqlBuilder can't drop a table with constraints with names longer than 60 characters

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.0 RC1
    • Core - SqlServer
    • None

    Description

      I get this error because the constraint name has been truncated to 60 characters (These are the same foreign keys i had trouble with in DDLUTILS-106, but on existing databases):

      'new_doc_permission_sets_ex_FK_meta_id_set_id_new_doc_permiss' is not a constraint. Query: IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'Tmp_new_doc_permission_sets')
      BEGIN
      DECLARE @reftable nvarchar(60), @constraintname nvarchar(60)
      DECLARE refcursor CURSOR FOR
      select reftables.name tablename, cons.name constraintname
      from sysobjects tables,
      sysobjects reftables,
      sysobjects cons,
      sysreferences ref
      where tables.id = ref.rkeyid
      and cons.id = ref.constid
      and reftables.id = ref.fkeyid
      and tables.name = 'Tmp_new_doc_permission_sets' OPEN refcursor
      FETCH NEXT from refcursor into @reftable, @constraintname
      while @@FETCH_STATUS = 0
      BEGIN
      exec ('alter table '@reftable' drop constraint '+@constraintname)
      FETCH NEXT from refcursor into @reftable, @constraintname
      END
      CLOSE refcursor
      DEALLOCATE refcursor
      DROP TABLE Tmp_new_doc_permission_sets
      END;

      Attachments

        1. DDLUTILS-109.patch
          0.8 kB
          Christoffer Hammarström

        Activity

          People

            tomdz Thomas Dudziak
            kreiger Christoffer Hammarström
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: