create table tt
(name1 text,
name2 varchar(20))insert tt
select 'aa','dd'select * from ttEXEC sp_dboption '你的数据库名称', 'select into/bulkcopy', 'true'
declare @sql varchar(500),@name char(30)declare cur cursor for
select name2 from ttopen curfetch next from cur into @namewhile @@fetch_status=0
begin
--set @a=len(@name)
set @sql='DECLARE @ptrval binary(16)
SELECT @ptrval = TEXTPTR(name1) 
   FROM tt where name2='''+rtrim(@name)+''''+'  UPDATETEXT tt.name1 @ptrval null 0 '''+rtrim(@name)+''''print(@sql)
exec (@sql)
fetch next from cur  into @name
end
EXEC sp_dboption '你的数据库名称', 'select into/bulkcopy', 'false'
GO

解决方案 »

  1.   

    --示例数据
    create table tb(name1 text,name2 varchar(20))
    insert tb select 'aa','dd'
    union all select 'bb','cc'
    go--处理
    declare @p binary(16),@name2 varchar(200)
    declare tb cursor local
    for
    select textptr(name1),
    name2+'aaa' --aaa是name2后面要附加的字符串
    from tbopen tb
    fetch tb into @p,@name2
    while @@fetch_status=0
    begin
    UPDATETEXT tb.name1 @p null 0 @name2
    fetch tb into @p,@name2
    end
    close tb
    deallocate tb
    select * from tb
    GO--删除测试
    drop table tb/*--结果
    name1        name2   
    ------------ --------
    aaddaaa      dd
    bbccaaa      cc(所影响的行数为 2 行)
    --*/
      

  2.   

    --示例数据
    create table tb(name1 text,name2 varchar(20))
    insert tb select 'aa','dd'
    union all select 'bb','cc'
    go--处理
    declare @p binary(16),@name2 varchar(200)
    declare tb cursor local
    for
    select textptr(name1),name2
    from tbopen tb
    fetch tb into @p,@name2
    while @@fetch_status=0
    begin
    UPDATETEXT tb.name1 @p null 0 @name2
    fetch tb into @p,@name2
    end
    close tb
    deallocate tb
    select * from tb
    GO--删除测试
    drop table tb/*--结果
    name1        name2   
    ------------ --------
    aadd         dd
    bbcc         cc(所影响的行数为 2 行)
    --*/
      

  3.   

    直接用吧:
    create table tt
    (name1 text,
    name2 varchar(20))insert tt
    select 'aa','dd'select * from ttEXEC sp_dboption '你的数据库名称'', 'select into/bulkcopy', 'true'
    declare @sql varchar(500),@name char(30),@a varchar(30)
    set @a='你的字符串'
    declare cur cursor for
    select name2 from ttopen curfetch next from cur into @namewhile @@fetch_status=0
    beginset @sql='DECLARE @ptrval binary(16)
    SELECT @ptrval = TEXTPTR(name1) 
       FROM tt where name2='''+rtrim(@name)+''''+'  UPDATETEXT tt.name1 @ptrval null 0 '''+rtrim(@name)+rtrim(@a)+''''exec (@sql)
    fetch next from cur  into @name
    end
    EXEC sp_dboption '你的数据库名称', 'select into/bulkcopy', 'false'
    GO
    /*
    --删除游标的。
    close cur
    deallocate cur
    */
      

  4.   

    结果:
    aadd你的字符串 dd