摘要:
alter table SubscribeList add id int identity(1,1)select max(id) as id into #t from SubscribeList group by maildelete from SubscribeList where id not in (select id from #t)drop table #talter table SubscribeList drop column id 删除表中重复字段,保留一个. 阅读全文
随笔分类 - SQLSERVER
t-sql 随机数
2011-09-28 14:18 by 河蟹社会, 229 阅读, 收藏,
摘要:
js:Math.floor(Math.random() * Array.length)SQL开发中会有生成随机数的需求,下面说几种常用的需求和解决办法(基于MS SQL),最后总结出通用的办法:1、0-9间的随机整数,包括0和9本身:abs(checksum(newid()))%10扩展从a-b间的随机整数(a,b本身也是整数):a+abs(checksum(newid()))%(b-a+1)2、0-1间的随机实数: rand()--或是 rand(checksum(newid()))--推荐使用后一种。由此扩展从a-b间的随机实数: a+rand(checksum(newid()))*(b- 阅读全文
浙公网安备 33010602011771号