Sunday, March 11, 2012

Cannot create compound unique index - server reports duplicate rows but there are none

Hi
I am using SQL Server 2000. I have a simple table (only 6 columns)
which currently contains a few hundred rows. There are two fields:
SupplierGroupID and RateAdjustmentDate, the combination of which
should never be repeated.
I am trying to create an index with these two fields specified and the
'Create Unique' box ticked, however, when I try to do this I get an
error saying that duplicate data was found.
There are no duplicates in the table. I have confirmed this by running
the SQL:
Select SupplierGroupID, RateAdjustmentDate, Count(SupplierGroupID)
from tblInvoiceRateAdjustment
Group By SupplierGroupID, RateAdjustmentID
All records report a count of 1.
I have tried this on two instances of SQL Server on two different
servers and get the same error with both.
Why is SQL Server reporting that this is duplicate data when there is
none?
TIA
PaulHi
http://dimantdatabasesolutions.blogspot.com/2007/02/dealing-with-duplicates.html
<pd_oflaherty@.hotmail.com> wrote in message
news:1172758648.458249.68170@.n33g2000cwc.googlegroups.com...
> Hi
> I am using SQL Server 2000. I have a simple table (only 6 columns)
> which currently contains a few hundred rows. There are two fields:
> SupplierGroupID and RateAdjustmentDate, the combination of which
> should never be repeated.
> I am trying to create an index with these two fields specified and the
> 'Create Unique' box ticked, however, when I try to do this I get an
> error saying that duplicate data was found.
> There are no duplicates in the table. I have confirmed this by running
> the SQL:
> Select SupplierGroupID, RateAdjustmentDate, Count(SupplierGroupID)
> from tblInvoiceRateAdjustment
> Group By SupplierGroupID, RateAdjustmentID
> All records report a count of 1.
> I have tried this on two instances of SQL Server on two different
> servers and get the same error with both.
> Why is SQL Server reporting that this is duplicate data when there is
> none?
> TIA
> Paul
>|||Thanks for posting but these links don't help me in this situation -
the issue is that there are NO duplicates of the field combination for
which I want to create a compound unique index.
I am certain there are no duplicates but still SQL will not allow the
index to be created.
On 1 Mar, 14:21, "Uri Dimant" <u...@.iscar.co.il> wrote:
> Hihttp://dimantdatabasesolutions.blogspot.com/2007/02/dealing-with-dupl...
> <pd_oflahe...@.hotmail.com> wrote in message
> news:1172758648.458249.68170@.n33g2000cwc.googlegroups.com...
>
> > Hi
> > I am using SQL Server 2000. I have a simple table (only 6 columns)
> > which currently contains a few hundred rows. There are two fields:
> > SupplierGroupID and RateAdjustmentDate, the combination of which
> > should never be repeated.
> > I am trying to create an index with these two fields specified and the
> > 'Create Unique' box ticked, however, when I try to do this I get an
> > error saying that duplicate data was found.
> > There are no duplicates in the table. I have confirmed this by running
> > the SQL:
> > Select SupplierGroupID, RateAdjustmentDate, Count(SupplierGroupID)
> > from tblInvoiceRateAdjustment
> > Group By SupplierGroupID, RateAdjustmentID
> > All records report a count of 1.
> > I have tried this on two instances of SQL Server on two different
> > servers and get the same error with both.
> > Why is SQL Server reporting that this is duplicate data when there is
> > none?
> > TIA
> > Paul- Hide quoted text -
> - Show quoted text -|||pd_oflaherty@.hotmail.com,
You should try:
Select SupplierGroupID, RateAdjustmentDate, Count(*)
from tblInvoiceRateAdjustment
Group By SupplierGroupID, RateAdjustmentDate
having count(*) > 1
go
AMB
"pd_oflaherty@.hotmail.com" wrote:
> Hi
> I am using SQL Server 2000. I have a simple table (only 6 columns)
> which currently contains a few hundred rows. There are two fields:
> SupplierGroupID and RateAdjustmentDate, the combination of which
> should never be repeated.
> I am trying to create an index with these two fields specified and the
> 'Create Unique' box ticked, however, when I try to do this I get an
> error saying that duplicate data was found.
> There are no duplicates in the table. I have confirmed this by running
> the SQL:
> Select SupplierGroupID, RateAdjustmentDate, Count(SupplierGroupID)
> from tblInvoiceRateAdjustment
> Group By SupplierGroupID, RateAdjustmentID
> All records report a count of 1.
> I have tried this on two instances of SQL Server on two different
> servers and get the same error with both.
> Why is SQL Server reporting that this is duplicate data when there is
> none?
> TIA
> Paul
>|||Forget it - I'm being a numpty - there is a duplicate, just didn't see
it despite flagging with a count and repeated scrolling. I either need
new specs or a bigger screen!
On 1 Mar, 14:55, pd_oflahe...@.hotmail.com wrote:
> Thanks for posting but these links don't help me in this situation -
> the issue is that there are NO duplicates of the field combination for
> which I want to create acompounduniqueindex.
> I am certain there are no duplicates but still SQL will not allow theindexto be created.
> On 1 Mar, 14:21, "Uri Dimant" <u...@.iscar.co.il> wrote:
>
> > Hihttp://dimantdatabasesolutions.blogspot.com/2007/02/dealing-with-dupl...
> > <pd_oflahe...@.hotmail.com> wrote in message
> >news:1172758648.458249.68170@.n33g2000cwc.googlegroups.com...
> > > Hi
> > > I am using SQL Server 2000. I have a simple table (only 6 columns)
> > > which currently contains a few hundred rows. There are two fields:
> > > SupplierGroupID and RateAdjustmentDate, the combination of which
> > > should never be repeated.
> > > I am trying to create an index with these two fields specified and the
> > > 'Create Unique' box ticked, however, when I try to do this I get an
> > > error saying that duplicate data was found.
> > > There are no duplicates in the table. I have confirmed this by running
> > > the SQL:
> > > Select SupplierGroupID, RateAdjustmentDate, Count(SupplierGroupID)
> > > from tblInvoiceRateAdjustment
> > > Group By SupplierGroupID, RateAdjustmentID
> > > All records report a count of 1.
> > > I have tried this on two instances of SQL Server on two different
> > > servers and get the same error with both.
> > > Why is SQL Server reporting that this is duplicate data when there is
> > > none?
> > > TIA
> > > Paul- Hide quoted text -
> > - Show quoted text -- Hide quoted text -
> - Show quoted text -

No comments:

Post a Comment