日期:2014-05-17 浏览次数:20592 次
----------------------------
-- Author :DBA_Huangzj(發糞塗牆)
-- Date :2013-04-17 21:42:24
-- Version:
-- Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (Intel X86)
-- Jun 17 2011 00:57:23
-- Copyright (c) Microsoft Corporation
-- Enterprise Edition on Windows NT 6.1 <X86> (Build 7601: Service Pack 1)
--
----------------------------
--> 测试数据:[huang]
if object_id('[huang]') is not null drop table [huang]
go
create table [huang]([条码] bigint,[品名] varchar(30))
insert [huang]
select 6935938850134,'富贵鸟弹力平角裤' union all
select 6935938851438,'富贵鸟拉毛印花女士保暖内衣' union all
select 6935938851445,'富贵鸟拉毛男士保暖内衣' union all
select 6935938851452,'富贵鸟拉毛印花男士保暖内衣' union all
select 6935938851469,'富贵鸟420G拉毛提花男士保暖内衣' union all
select 6935938867415,'富贵鸟男士休闲袜2双装'
--------------开始查询--------------------------
select *, IDENTITY(INT,1,1)id INTO #t
from [huang] a
SELECT * FROM #t
----------------结果----------------------------
/*
条码 品名 id
-------------------- ------------------------------ -----------
6935938850134 富贵鸟弹力平角裤 1
6935938851438 富贵鸟拉毛印花女士保暖内衣 2
6935938851445 富贵鸟拉毛男士保暖内衣 3
6935938851452 富贵鸟拉毛印花男士保暖内衣 4
6935938851469 富贵鸟420G拉毛提花男士保暖内衣 5
6935938867415 富贵鸟男士休闲袜2双装 6
*/