create table t_panda1(stext varchar(500))
insert into t_panda1
select '695'
union all select '00:56:01,476 --> 00:56:04,045'
union all select ''
union all select ''
union all select '- 我可以吗?'
union all select '- 你可以吗?'
union all select ''
union all select '696'
union all select '00:57:28,155 --> 00:57:30,694'
union all select ''
union all select ''
union all select '我不饿了'
union all select ''
union all select '697'
union all select '00:57:33,180 --> 00:57:34,979'
union all select ''
union all select ''
union all select '师父'--select * from t_panda1
最后成这样的数据695
00:56:01,476 --> 00:56:04,045
- 我可以吗?
- 你可以吗?696
00:57:28,155 --> 00:57:30,694
我不饿了697
00:57:33,180 --> 00:57:34,979
师父

解决方案 »

  1.   

    如果不加ID列好像沒有辦法刪除非手動刪除
    create table #t_panda1(stext varchar(500))
    insert into #t_panda1
    select '695'
    union all select '00:56:01,476 --> 00:56:04,045'
    union all select ''
    union all select ''
    union all select '- 我可以吗?'
    union all select '- 你可以吗?'
    union all select ''
    union all select '696'
    union all select '00:57:28,155 --> 00:57:30,694'
    union all select ''
    union all select ''
    union all select '我不饿了'
    union all select ''
    union all select '697'
    union all select '00:57:33,180 --> 00:57:34,979'
    union all select ''
    union all select ''
    union all select '师父'
    Select identity(int,1,1)as id, * into #t from #t_panda1delete from #t where id in
    (
    select id from #t where exists(select 1 from #t s where s.stext='' and s.id=#t.id+1) and stext='' 
    union 
    select id+1 from #t where exists(select 1 from #t s where s.stext='' and s.id=#t.id+1) and stext='' 
    )
    select * from #tdrop table #t