---------------------------------------------------------------- -- Author :DBA_HuangZJ(發糞塗牆) -- Date :2014-11-21 10:10:35 -- Version: -- Microsoft SQL Server 2014 (CTP1) - 11.0.9120.5 (X64) -- Jun 10 2013 20:09:10 -- Copyright (c) Microsoft Corporation -- Enterprise Edition: Core-based Licensing (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor) -- ---------------------------------------------------------------- --> 测试数据:[A] if object_id('[A]') is not null drop table [A] go create table [A]([a] int) insert [A] select 1 union all select 3 union all select 5 union all select 7 union all select 9 --------------开始查询--------------------------select top 1 * from [A] order by checksum(newid()) ----------------结果---------------------------- /* a ----------- 5*/
-- Author :DBA_HuangZJ(發糞塗牆)
-- Date :2014-11-21 10:10:35
-- Version:
-- Microsoft SQL Server 2014 (CTP1) - 11.0.9120.5 (X64)
-- Jun 10 2013 20:09:10
-- Copyright (c) Microsoft Corporation
-- Enterprise Edition: Core-based Licensing (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor)
--
----------------------------------------------------------------
--> 测试数据:[A]
if object_id('[A]') is not null drop table [A]
go
create table [A]([a] int)
insert [A]
select 1 union all
select 3 union all
select 5 union all
select 7 union all
select 9
--------------开始查询--------------------------select top 1 *
from [A]
order by checksum(newid())
----------------结果----------------------------
/*
a
-----------
5*/