34,587
社区成员
发帖
与我相关
我的任务
分享
use Tempdb
go
--> -->
if not object_id(N'Tempdb..#T') is null
drop table #T
Go
Create table #T([a] nvarchar(27),[b] int,[c] nvarchar(22))
Insert #T
select N'ds;df;w',1,N'sd' union all
select N'xc;c',2,N'df' union all
select N'a',3,N'df'
Go
Select
[a]=substring(a.[a],b.number,charindex(';',a.[a]+';',b.number)-b.number) ,[b],[c]
from
#T a,master.dbo.spt_values b
where
b.type='P' AND b.number>=1 AND charindex(';',';'+a.[a],b.number)=b.number
/*
a b c
ds 1 sd
df 1 sd
w 1 sd
xc 2 df
c 2 df
a 3 df
*/