Invalid Index specification leads to exception

urs.meiliurs.meili Posts: 13
edited February 26, 2013 4:46PM in SQL Compare Previous Versions
Hi,
I have the following SQL script which SQL Compare is processing using the "compare with files" option:

CREATE TABLE [dbo].[tblMutationHistory]
(
[IDMutationHistory] [int] NOT NULL IDENTITY(1, 1),
[MHistObjArt] [smallint] NOT NULL,
[MHistObjKey1] [int] NOT NULL,
[MHistObjKey2] [int] NULL,
[MHistTimeStamp] [datetime] NOT NULL DEFAULT (getdate()),
[MHistIdBenutzer] [varchar] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[MHistGrund] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[MHistMutation] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[MHistObjKey3] [int] NULL,
[MHistGuid] [uniqueidentifier] NULL -- Eindeutige GUID für diesen Mutationhistory-Eintrag
)
ALTER TABLE [dbo].[tblMutationHistory] ADD CONSTRAINT [PK__MutationHistory__3521D83F] PRIMARY KEY CLUSTERED ([IDMutationHistory])
CREATE NONCLUSTERED INDEX [MHistObjArt] ON [dbo].[tblMutationHistory] ([MHistObjArt])
CREATE NONCLUSTERED INDEX [MHistObjKey1] ON [dbo].[tblMutationHistory] ([MHistObjKey1])
CREATE NONCLUSTERED INDEX [MHist_GuidMutationHistory] ON [dbo].[tblMutationHistory] ([GuidMutationHistory])

This results in an exception "Failed to compare two elements in the array." within SQL Compare 10 (API).

The reason seems to be that the field in the index [MHist_GuidMutationHistory] is wrongly named ("[GuidMutationHistory]" instead of "[MHistGuid]".

I corrected the error in the script. However, it would be a good idea if SQL Compare would print a decent error message instead of just quitting with an arbitrary exception.

Comments

Sign In or Register to comment.