Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
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;