Debtor System Templates errors with a Duplicate Field Name issue when using the same field name in different templates

Problem

Using Debtor Systems to track the service of items sold to their customers encounters an issue where multiple Debtor system templates cannot have the same field name in version 7.0.175 and prior

Solution

SQL skills are required

Sounds SQL skills are required to complete this task.

The work-around for 7.00.175 and prior is to drop the index and re-create as a composite unique index on TemplateID and Name.  The following script does this:

IF EXISTS(SELECT * FROM sys.indexes WHERE Name = 'IX_DB_DebtorSystemTemplateFields_Name')
DROP INDEX DB_DebtorSystemTemplateFields.IX_DB_DebtorSystemTemplateFields_Name
GO

IF NOT EXISTS(SELECT * FROM sys.indexes WHERE Name = 'IX_DB_DebtorSystemTemplateFields_DB_DebtorSystemTemplates_RecID_Name')
CREATE UNIQUE INDEX IX_DB_DebtorSystemTemplateFields_DB_DebtorSystemTemplates_RecID_Name ON DB_DebtorSystemTemplateFields(DB_DebtorSystemTemplates_RecID, Name)
GO