日期:2014-05-16 浏览次数:20642 次
----------------------------------------------------------------
-- Author :DBA_Huangzj(發糞塗牆)
-- Date :2014-02-11 18:01:08
-- Version:
-- Microsoft SQL Server 2012 (SP1) - 11.0.3128.0 (X64)
-- Dec 28 2012 20:23:12
-- Copyright (c) Microsoft Corporation
-- Enterprise Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: )
--
----------------------------------------------------------------
--> 测试数据:[HUANG]
if object_id('[HUANG]') is not null drop table [HUANG]
go
create table [HUANG]([column1] int,[column2] int,[column3] int,[column4] int,[column5] int)
insert [HUANG]
select 1,2,3,4,5 union all
select 11,22,33,44,55 union all
select 111,222,333,444,555 union all
select 1111,2222,3333,4444,5555 union all
select 1111,2222,3333,4444,5555
--------------开始查询--------------------------
select * ,ROW_NUMBER()OVER(ORDER BY column1)id
from [HUANG]
----------------结果----------------------------
/*
column1 column2 column3 column4 column5 id
----------- ----------- ----------- ----------- ----------- --------------------
1 2 3 4 5 1
11 22 33 44 55 2
111 222 333 444