在Text字段尾部追加数据

来源:互联网 发布:虚拟机没有网络连接 编辑:程序博客网 时间:2024/05/17 09:06

在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 行)
--*/

原帖地址



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=384496


原创粉丝点击