怎么把一张表的一个text类型的字段,导到另一张表的一个text类型的字段 你想怎样过去?dts insertupdate可以直接执行sql语句,不经过变量不行吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 楼主的要求用游标+ updatetext 即可实现updatetext的来源可以是text指针的, 如果你要经过处理, 可以先把数据放入临时表, 处理完成后再放入正式表 -- 这个示例和楼主的需求比较相似(游标+合并的处理)create table news( title1 nvarchar(10),content1 ntext, title2 nvarchar(10),content2 ntext, title3 nvarchar(10),content3 ntext, title4 nvarchar(10),content4 ntext)insert news select '1','aa','2','bb','3','cc','4','dd'union all select '11','aaa','22','bbb','33','ccc','44','ddd'union all select '111','aaaa','222','bbbb','333','cccc','444','dddd'create table article(id int identity,title nvarchar(20),content ntext)go--类似这样处理declare @p binary(16),@p1 binary(16),@p2 binary(16),@p3 binary(16),@p4 binary(16) ,@t nvarchar(4000) ,@t1 nvarchar(4000),@t2 nvarchar(4000),@t3 nvarchar(4000),@t4 nvarchar(4000)declare tb cursor local forselect title1+'等' ,'<div align=center><font size=4>'+title1+'</div></font><br> ' ,textptr(content1) ,'<div align=center><font size=4>'+title2+'</div></font><br> ' ,textptr(content2) ,'<div align=center><font size=4>'+title3+'</div></font><br> ' ,textptr(content3) ,'<div align=center><font size=4>'+title4+'</div></font><br> ' ,textptr(content4)from newsopen tbfetch tb into @t,@t1,@p1,@t2,@p2,@t3,@p3,@t4,@p4while @@fetch_status=0begin insert article(title,content) values(@t,@t1) select @p=textptr(content) from article where id=@@identity --如果 article 表没有自增字段,则不要这个条件(效果一样,但影响效率) updatetext article.content @p null 0 news.content1 @p1 updatetext article.content @p null 0 @t2 updatetext article.content @p null 0 news.content2 @p2 updatetext article.content @p null 0 @t3 updatetext article.content @p null 0 news.content3 @p3 updatetext article.content @p null 0 @t4 updatetext article.content @p null 0 news.content4 @p4 fetch tb into @t,@t1,@p1,@t2,@p2,@t3,@p3,@t4,@p4endclose tbdeallocate tbgoselect * from articlegodrop table article,news 都来看看,见者有分 关于新建登录账户的一个问题, 【All】求如何判断字段是否是外键? 一个小问题,大家帮帮忙 如何用其他表中得纪录替换当前表的纪录?(1对多) 数据转移过程中空间不够了 高手们,请教最实用的SQL的并发控制办法, 紧急求助:sqlserver2005连接的时候出错,未能加载文件或程序集。。。。。? sql server 单机版 安装SQL Server 2000时为什么到最后说“安装程序配置服务器失败”,怎么解决啊? 请教一个SQL话句 求一最优sql,速度
title1 nvarchar(10),content1 ntext,
title2 nvarchar(10),content2 ntext,
title3 nvarchar(10),content3 ntext,
title4 nvarchar(10),content4 ntext)
insert news select '1','aa','2','bb','3','cc','4','dd'
union all select '11','aaa','22','bbb','33','ccc','44','ddd'
union all select '111','aaaa','222','bbbb','333','cccc','444','dddd'
create table article(id int identity,title nvarchar(20),content ntext)
go--类似这样处理
declare @p binary(16),@p1 binary(16),@p2 binary(16),@p3 binary(16),@p4 binary(16)
,@t nvarchar(4000)
,@t1 nvarchar(4000),@t2 nvarchar(4000),@t3 nvarchar(4000),@t4 nvarchar(4000)
declare tb cursor local for
select title1+'等'
,'<div align=center><font size=4>'+title1+'</div></font><br> '
,textptr(content1)
,'<div align=center><font size=4>'+title2+'</div></font><br> '
,textptr(content2)
,'<div align=center><font size=4>'+title3+'</div></font><br> '
,textptr(content3)
,'<div align=center><font size=4>'+title4+'</div></font><br> '
,textptr(content4)
from news
open tb
fetch tb into @t,@t1,@p1,@t2,@p2,@t3,@p3,@t4,@p4
while @@fetch_status=0
begin
insert article(title,content) values(@t,@t1)
select @p=textptr(content) from article
where id=@@identity --如果 article 表没有自增字段,则不要这个条件(效果一样,但影响效率)
updatetext article.content @p null 0 news.content1 @p1
updatetext article.content @p null 0 @t2
updatetext article.content @p null 0 news.content2 @p2
updatetext article.content @p null 0 @t3
updatetext article.content @p null 0 news.content3 @p3
updatetext article.content @p null 0 @t4
updatetext article.content @p null 0 news.content4 @p4
fetch tb into @t,@t1,@p1,@t2,@p2,@t3,@p3,@t4,@p4
end
close tb
deallocate tb
goselect * from article
godrop table article,news