日期:2014-05-17 浏览次数:20416 次
----------------------------------------------------------------
-- Author :DBA_Huangzj(發糞塗牆)
-- Date :2013-12-24 14:24:18
-- 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]([id] int,[name] varchar(6),[ischeck] int)
insert [huang]
select 1,'jack',null union all
select 2,'tony',null union all
select 3,'amanda',null union all
select 4,'xiao',null union all
select 5,'ming',null
--------------开始查询--------------------------
select ID,NAME,ROW_NUMBER()OVER(ORDER BY id)[ischeck]
from [huang]
----------------结果----------------------------
/*
ID NAME ischeck
----------- ------ --------------------
1 jack 1
2 tony 2
3 amanda 3
4 &