Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 index - error

Author  Topic 

kiri
Starting Member

38 Posts

Posted - 2008-02-25 : 10:12:38
CREATE unique clustered INDEX salesdate_index ON salesdocumentry(salesdate)
WITH (IGNORE_DUP_KEY = ON);
GO

getting error:

The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'dbo.salesdocumentry' and the index name 'salesdate_index' . The duplicate key value is (Jan 1 1900 12:00AM).
The statement has been terminated.

can anyone guide what should i do?

thanks.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-25 : 10:15:35
1) Locate the already existing duplicate records and decide what to do with them.
2) Why would you like to do a UNIQUE clustered index over a datetime column?


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

kiri
Starting Member

38 Posts

Posted - 2008-02-25 : 10:22:22
In my procedure i have to pass salesdate and will get all sales results..so to get results faster i have to create index on datecolumn.

if i m creating nonclustered index it bot gives me error but query is not running fast...so i m trying to create clustered index.

can u tell me whether i have to create just cluster index or uique cluster index.

thanks for ur help and guidance.
Go to Top of Page

Abu-Dina
Posting Yak Master

206 Posts

Posted - 2008-02-25 : 10:26:35
quote:
2) Why would you like to do a UNIQUE clustered index over a datetime column?



It could be a daily aggregate table in which case a unique index on the date could be feasible IMHO.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-25 : 10:35:45
quote:
Originally posted by kiri

The duplicate key value is (Jan 1 1900 12:00AM).
You have at least two records with value 0 (Jan 1 1900 12:00AM) in the column.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-25 : 10:36:25
You can still make the index clustered and having it non-unique.

CREATE unique clustered INDEX salesdate_index ON salesdocumentry (salesdate)



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2008-02-25 : 10:41:05
How many rows are we talking about?

I don't buy it btw



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

kiri
Starting Member

38 Posts

Posted - 2008-02-25 : 10:47:51
i can run my query fast better than previous - before indexing...so after creating cluster index...i m getting results faster..

thanks peso.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-25 : 10:54:09
Please notice that adding a CLUSTERED index severely affects future DELETE and INSERT statements.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

kiri
Starting Member

38 Posts

Posted - 2008-02-25 : 11:08:48
sure peso..will keep in mind.

thanks a lot!!
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2008-02-25 : 11:30:54
I would really like to know how much data you have, and what sql you are executing



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

kiri
Starting Member

38 Posts

Posted - 2008-02-25 : 11:52:30
quote:
Originally posted by X002548

I would really like to know how much data you have, and what sql you are executing



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link


i m using sql 2005 and i have more than 6000 rows
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam





Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2008-02-25 : 13:59:55
I think you forgot something



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -