`
javayestome
  • 浏览: 1007251 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

在Text字段尾部追加数据

Go 
阅读更多

在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

/*--结果
name1name2
------- --------
aadddd
bbcccc

(所影响的行数为 2 行)
--*/

原帖地址

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics