日期:2014-05-18  浏览次数:20373 次

请问高手一个问题 SQL的 ntext字段 如何进行update 叠加?
请问高手一个问题 SQL的 ntext字段 如何进行update 叠加?
比如 让一个ntext字段的aaa=aaa+"123123" 这个操作如何实现?

如果直接在程序 操作会出现“数据类型问题 ntext类型为add 什么的” 请问该怎么办? 救命!!

------解决方案--------------------
这样可以 吗
SQL code


declare @t table(ID ntext)
insert into @t select 'asf'
select ID =cast(ID as nvarchar) + cast('123456' as nvarchar) from @t

------解决方案--------------------
SQL code
create table T(Name text)
go
insert T select 'aaaa'

----2000支持8000个字符,2005用nvarcahr(max)/varchar(max)--与text大小一样
update T
set Name=cast(Name as varchar(8000))+'123'
from 
    T

select * from T


aaaa123

(所影响的行数为 1 行)

------解决方案--------------------
SQL code
create table T(Name text)
go
insert T select 'aaaa'


SQL2000text大于8000:

declare test cursor for
select textptr(Name)  from T 
declare @p binary(16)
open test
fetch next from test into @p
while @@fetch_status=0
begin
    updatetext T.Name @p null 0 '1234'
    fetch next from test into @p
end
close test
deallocate test
go

select * from T

aaaa1231234

(所影响的行数为 1 行)