在Text字段尾部追加数据 问题描述: 表 tt 含字段 name1 text 类型 name2 varchar类型 (值可能为 null),现要将 name2的值添加到 name1里边。 --示例数据 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 tb
open 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 行) --*/ 原帖地址
|