T-SQL update 表中一列为不重复的5位随机数
alter table tb add id int update tb set id=substring(LTrim(abs(checksum(newid()))),0,6)
checksum(newid()) 这个的数据是唯一的,但是只取其中的一部分之后,就把重复的可能性加大了。
谢祥选【小宇飞刀(xieyunc)】
alter table tb add id int update tb set id=substring(LTrim(abs(checksum(newid()))),0,6)
checksum(newid()) 这个的数据是唯一的,但是只取其中的一部分之后,就把重复的可能性加大了。