当前位置: 代码迷 >> Sql Server >> 问一个datetime字段类型创建unique clustered index异常
  详细解决方案

问一个datetime字段类型创建unique clustered index异常

热度:103   发布时间:2016-04-27 14:51:21.0
问一个datetime字段类型创建unique clustered index错误
create unique clustered index id_updated on v_aaa(updated);老是提示记录重复无法创建的错误。
里面的数据明明没有重复啊。
updated值如下
2001-12-12 00:11:25.012
2001-12-12 00:11:25.013
2001-12-12 00:11:25.014
2001-12-12 00:11:25.015
2001-12-12 00:11:25.016
2001-12-12 00:11:25.017
2001-12-12 00:11:25.018



数值就是上面列出的值,明明每一都不同啊,但是老是提示错误,晕倒。


------解决方案--------------------
微秒数,精确度不够.不建唯一索引,直接插入后运行一下,你就知道了:
SQL code
create table tb(dt datetime)insert into tb select '2001-12-12 00:11:25.012'insert into tb select '2001-12-12 00:11:25.013'insert into tb select '2001-12-12 00:11:25.014'insert into tb select '2001-12-12 00:11:25.015'insert into tb select '2001-12-12 00:11:25.016'insert into tb select '2001-12-12 00:11:25.017'insert into tb select '2001-12-12 00:11:25.018'goselect * from tb/*dt-----------------------2001-12-12 00:11:25.0132001-12-12 00:11:25.0132001-12-12 00:11:25.0132001-12-12 00:11:25.0172001-12-12 00:11:25.0172001-12-12 00:11:25.0172001-12-12 00:11:25.017(7 行受影响)*/godrop table tb
  相关解决方案