日期:2014-05-17 浏览次数:20429 次
----------------------------------------------------------------
-- Author :DBA_Huangzj(發糞塗牆)
-- Date :2013-12-16 12:33:35
-- 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: )
--
----------------------------------------------------------------
--> 测试数据:[B]
if object_id('[B]') is not null drop table [B]
go
create table [B]([人员Id] int,[卡片号码] varchar(8))
insert [B]
select 1,'01235' union all
select 1,'0123456' union all
select 1,'01234567' union all
select 2,'02345' union all
select 2,'023456'
--------------开始查询--------------------------
declare @s nvarchar(4000)
set @s=''
Select @s=@s+','+quotename('卡片'+CONVERT(VARCHAR(2),ROW_NUMBER()OVER(ORDER