My FAQ,最新最全的IT技术FAQ
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 未整理篇 | 技术讨论
  当前位置: > 程序开发 > 数据库开发 > 数据库综合
在Text字段尾部追加数据
作者:未知 时间:2005-07-27 23:40 出处:CSDN 责编:My FAQ
              摘要:在Text字段尾部追加数据

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

原帖地址


 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 myfaq.com.cn All rights reserved. www.myfaq.com.cn 版权所有