SQL codeSELECT TOP 1000 * FROM tb ORDER BY NEWID() [/Quote]
select top 1000 distinct * from tb ORDER BY NEWID()
select top 1000 distinct * from tb ORDER BY NEWID()
select top 1000 distinct * from tb ORDER BY NEWID()
select top 1000 distinct * from tb ORDER BY NEWID()
表A a b 1 w 2 q 3 n 4 e .... 如何随机提取表A中的N条数据(比如1000条),并且数据不能重复并且生成1个这N个数据的新表 TB1?
select top 1000 distinct * into TB1 from tb ORDER BY NEWID() --TB1事先不存在 insert TB1 select top 1000 distinct * from tb ORDER BY NEWID() --TB1事先存在.且结构与tb匹配
谢谢您的回复,为什么加入distinct去掉重复值就提示有语法错误,去掉distinct就可以那?
select top 1000 * from (select distinct * from tb) t ORDER BY NEWID() select top 1000 * into tb1 from (select distinct * from tb) t ORDER BY NEWID()
FROM tb
ORDER BY NEWID()
SQL codeSELECT TOP 1000 *
FROM tb
ORDER BY NEWID()
[/Quote]
select top 1000 distinct * from tb ORDER BY NEWID()
1 w
2 q
3 n
4 e
.... 如何随机提取表A中的N条数据(比如1000条),并且数据不能重复并且生成1个这N个数据的新表 TB1?
insert TB1 select top 1000 distinct * from tb ORDER BY NEWID() --TB1事先存在.且结构与tb匹配
select top 1000 * from (select distinct * from tb) t ORDER BY NEWID() select top 1000 * into tb1 from (select distinct * from tb) t ORDER BY NEWID()