Q: Primary key constraint violation with datetime field 
Author Message
 Q: Primary key constraint violation with datetime field

SQL V6.5 (no SPs)

I have a Primary Key Constraint on one of my tables that contains three
fields, one of them being a datetime format.  I am getting "violation
of primary key constraint" errors and figure that the only place it
could be happening is with the datetime field.  I understand that the
granularity for datetime fields is milliseconds so am at a loss as to
why the constraint is failing (I assume that it is not possible to have
two separate transactions occur in the same millisecond time window).
Is it possible that my SQLServer installation has some sort of setting
that is causing the granularity of the datetime field to be lowered?

Help?  Will I have to add extra data to the constraint to ensure
uniqueness or change the settings of the SQLServer installation?  Is
the hardware so good that it could be creating a bottleneck that sees
two inserts in the same millisecond?

Many thanks,

James.



Tue, 23 Nov 1999 03:00:00 GMT
 Q: Primary key constraint violation with datetime field


Quote:
>I have a Primary Key Constraint on one of my tables that contains three
>fields, one of them being a datetime format.  I am getting "violation
>of primary key constraint" errors and figure that the only place it
>could be happening is with the datetime field.  I understand that the
>granularity for datetime fields is milliseconds so am at a loss as to
>why the constraint is failing (I assume that it is not possible to have
>two separate transactions occur in the same millisecond time window).
>Is it possible that my SQLServer installation has some sort of setting
>that is causing the granularity of the datetime field to be lowered?

But who is generating data for the datetime field? If it is generated
by a client which only has a granularity of seconds, it is no longer
strange that you get duplicates.

Quote:
>Help?  Will I have to add extra data to the constraint to ensure
>uniqueness or change the settings of the SQLServer installation?  

You may want to look at IDENTITY columns as an alternate way to get
a primary key.

It would be more fruitful if you included the table definitions in your
posting, so we who are giving it a stab are not just fumbling in the
dark.

You should also fix your reply address. The one included in your posting
does not seem useful. At least I haven't heard of a mapson domain...

--

F=F6r =F6vrigt anser jag att QP b=F6r f=F6rst=F6ras.
B=65sid=65s, I think QP should b=65 d=65stroy=65d.



Wed, 24 Nov 1999 03:00:00 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. Violation of PRIMARY KEY constraint Cannot insert duplicate key in object

2. Violation of PRIMARY KEY constraint ??

3. Violation of primary key constraint

4. ODBC Violation of Primary Key Constraint Can't Update Reord

5. Violation of Primary Key Constraint

6. Violation of Primary Key constraint

7. Violation of PRIMARY KEY constraint with identity!

8. Violation of PRIMARY KEY constraint

9. Violation of PRIMARY KEY constraint

10. Violation of PRIMARY KEY constraint

11. Violation of PRIMARY KEY constraint


 
Powered by phpBB® Forum Software