日期:2014-05-17 浏览次数:20471 次
----------------------------------------------------------------
-- Author :fredrickhu(小F,向高手学习)
-- Date :2013-11-22 16:44:32
-- Verstion:
-- Microsoft SQL Server 2012 - 11.0.2100.60 (X64)
-- Feb 10 2012 19:39:15
-- Copyright (c) Microsoft Corporation
-- Enterprise Edition: Core-based Licensing (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
--
----------------------------------------------------------------
--> 测试数据:[tb]
if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([id] int,[unit] varchar(5))
insert [tb]
select 12,'201+1' union all
select 12,'20' union all
select 12,'321' union all
select 15,'3/PNL' union all
select 15,'/' union all
select 15,'23' union all
select 15,'658.1'
--------------开始查询--------------------------
IF object_id('tempdb..#tb') IS NOT NULL
DROP TABLE #tb
go
CREATE TABLE #tb
(
[id] int,[unit] varchar(5)
)
go
INSERT INTO #tb SELECT id,unit&nbs