SQL数据如何循环? 你要做什么?看上去感觉不需要用循环,row_number()应该能够处理你的问题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://blog.csdn.net/wufeng4552/article/details/4534365 create table #table1( os_no varchar(100) null, pn_po varchar(500) null)create table #last( os_no varchar(100) null, pn_po varchar(500) null)create table #linshi( os_no varchar(100) null, pn_po varchar(500) null)insert into #table1select 'SOBZ111121LOG01','PO-138490' unionselect 'SOBZ130819ZAL01','PO-1006818/PO-1006820/PO-1006823/PO-1006825' unionselect 'SOBZ130517FRE01','PO-1004245/PO-1004248/PO-1004426/PO-1004661' select * From #table1declare @i int,@max intset @i=1select @max=max(LEN(pn_po)) from #table1while @i<@maxbegin insert into #last select * from #table1 where CHARINDEX('/',pn_po)=0 delete #table1 where CHARINDEX('/',pn_po)=0 insert into #last select os_no,substring(pn_po,1,CHARINDEX('/',pn_po)-1) from #table1 insert into #linshi select os_no,substring(pn_po,CHARINDEX('/',pn_po)+1,LEN(pn_po)) from #table1 truncate table #table1 insert into #table1 select * from #linshi truncate table #linshi select @i=@i+1endselect * from #last结果: 帮忙看个sql啊 请教如何按名称把某一时间段内的最大值,最小值,及平均值,还有它们的时间统计出来呢 sql2000中money类型小数点前显示零? 请教高人..面对oralce如何解决??? 必须声明标量变量 "@indextable"。 SQL动态新增列位置问题 求助:Sql Server服务管理器无法启动了 想问delphi变量怎么给到存储过程中 请问大家,怎么样可以取得sql server 2000当前的死锁信息???谢谢大家 请教几个问题,希望各位大大帮小弟一下 求助 sql语句 求大师帮助! 求以一存储过程
os_no varchar(100) null,
pn_po varchar(500) null
)
create table #last(
os_no varchar(100) null,
pn_po varchar(500) null
)
create table #linshi(
os_no varchar(100) null,
pn_po varchar(500) null
)insert into #table1
select 'SOBZ111121LOG01','PO-138490' union
select 'SOBZ130819ZAL01','PO-1006818/PO-1006820/PO-1006823/PO-1006825' union
select 'SOBZ130517FRE01','PO-1004245/PO-1004248/PO-1004426/PO-1004661' select * From #table1declare @i int,@max int
set @i=1
select @max=max(LEN(pn_po)) from #table1
while @i<@max
begin insert into #last
select * from #table1 where CHARINDEX('/',pn_po)=0
delete #table1 where CHARINDEX('/',pn_po)=0 insert into #last
select os_no,substring(pn_po,1,CHARINDEX('/',pn_po)-1) from #table1 insert into #linshi
select os_no,substring(pn_po,CHARINDEX('/',pn_po)+1,LEN(pn_po)) from #table1 truncate table #table1
insert into #table1
select * from #linshi
truncate table #linshi
select @i=@i+1
endselect * from #last
结果: