首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2012-02-24 
问一个datetime字段类型创建unique clustered index错误create unique clustered index id_updated on v_a

问一个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 

热点排行