这个在SQL中好像处理不到,除非你的text字段长度没有超过8000

解决方案 »

  1.   

    zjcxc(邹建),,我的这个字段不会超过8000的,,请帮忙,,我急阿
      

  2.   

    --处理的存储过程
    create proc p_process
    as
    create table #t(bz text)
    insert #t values('')declare @s varchar(8000),@p varbinary(16)
    declare tb cursor local for 
    select s=convert(varchar(8000),bz)+char(13) from bj_cpjg
    select @p=textptr(bz) from #t
    open tb 
    fetch next from tb into @s
    while @@fetch_status=0
    begin
    updatetext #t.bz @p null 0 @s
    fetch next from tb into @s
    end
    close tb
    deallocate tbselect * from #t
    go--调用存储过程进行处理
    exec p_process
      

  3.   

    --测试--测试数据
    create table bj_cpjg(id int identity(1,1),bz text)
    insert bj_cpjg select '这是第一行的数据'
    union  all     select '这是第二行的数据'
    union  all     select '这是第三行的数据'
    union  all     select '这是第四行的数据'
    go--处理的存储过程
    create proc p_process
    as
    create table #t(bz text)
    insert #t values('')declare @s varchar(8000),@p varbinary(16)
    declare tb cursor local for 
    select s=convert(varchar(8000),bz)+char(13) from bj_cpjg
    select @p=textptr(bz) from #t
    open tb 
    fetch next from tb into @s
    while @@fetch_status=0
    begin
    updatetext #t.bz @p null 0 @s
    fetch next from tb into @s
    end
    close tb
    deallocate tbselect * from #t
    go--调用存储过程进行处理
    exec p_process
    go--删除测试
    drop table bj_cpjg
    drop proc p_process/*--测试结果
    bz                            
    ------------------------------
    这是第一行的数据
    这是第二行的数据
    这是第三行的数据
    这是第四行的数据
    (所影响的行数为 1 行)
    --*/