﻿IF (object_id( 'tipopagto' ) IS NOT NULL)
	BEGIN
		declare @sql nvarchar(max) = (select 
      'alter table ' + quotename(schema_name(schema_id)) + '.' +
      quotename(object_name(parent_object_id)) +
      ' drop constraint '+quotename(name) + ';'
			from sys.foreign_keys s
			where object_name(referenced_object_id) = 'tipopagto' for xml path('')
			)
	EXEC sp_executesql @sql;
END