日期:2014-05-17 浏览次数:20642 次
----------------------------
-- Author :DBA_Huangzj(發糞塗牆)
-- Date :2013-02-22 17:00:18
-- Version:
-- Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64)
-- Jun 17 2011 00:54:03
-- Copyright (c) Microsoft Corporation
-- Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1, v.721)
--
----------------------------
--> 测试数据:[huang]
if object_id('[huang]') is not null drop table [huang]
go
create table [huang]([QXLB] varchar(44))
insert [huang]
select '0654,0655,0656,0657,0658,0659,0660,0661,0662'
--------------开始查询--------------------------
SELECT SUBSTRING([QXLB], number, CHARINDEX(',', [QXLB] + ',', number) - number) AS [QXLB]
FROM huang a ,
master..spt_values
WHERE number >= 1
AND number < LEN([QXLB])
AND type = 'p'
AND SUBSTRING(',' + [QXLB], number, 1) = ','
----------------结果----------------------------
/*
QXLB
--------------------------------------------
0654
0655
0656
0657
0658
0659
0660
0661
0662
*/
CREATE TABLE OA_Group(ZWBH NVARCHAR(4000), QXLB NVARCHAR(4000))