字符串
char固定长度的非 Unicode 字符数据,最大长度为 8,000 个字符。varchar可变长度的非 Unicode 数据,最长为 8,000 个字符。text可变长度的非 Unicode 数据,最大长度为 2^31 - 1 (2,147,483,647) 个字符。Unicode 字符串
nchar固定长度的 Unicode 数据,最大长度为 4,000 个字符。 nvarchar可变长度 Unicode 数据,其最大长度为 4,000 字符。sysname 是系统提供用户定义的数据类型,在功能上等同于 nvarchar(128),用于引用数据库对象名。ntext可变长度 Unicode 数据,其最大长度为 2^30 - 1 (1,073,741,823) 个字符。
char固定长度的非 Unicode 字符数据,最大长度为 8,000 个字符。varchar可变长度的非 Unicode 数据,最长为 8,000 个字符。text可变长度的非 Unicode 数据,最大长度为 2^31 - 1 (2,147,483,647) 个字符。Unicode 字符串
nchar固定长度的 Unicode 数据,最大长度为 4,000 个字符。 nvarchar可变长度 Unicode 数据,其最大长度为 4,000 字符。sysname 是系统提供用户定义的数据类型,在功能上等同于 nvarchar(128),用于引用数据库对象名。ntext可变长度 Unicode 数据,其最大长度为 2^30 - 1 (1,073,741,823) 个字符。
insert into hello
select '<IMG align=baseline alt="" border=0 src="http://localhost/upimg/0335_p1.jpg"><BR>'
union all select '<IMG align=baseline alt="" border=0 src="http://localhost/upimg/0335_p1.jpg"><BR>'--定义替换/删除的字符串
declare @s_str varchar(8000),@d_str varchar(8000)
select @s_str='http://localhost/' --要替换的字符串
,@d_str='' --替换成的字符串--定义游标,循环处理数据
declare @id int
declare #tb cursor for select id from hello
open #tb
fetch next from #tb into @id
while @@fetch_status=0
begin
--字符串替换处理
declare @p varbinary(16),@postion int,@rplen int
select @p=textptr(CONTENT),@rplen=len(@s_str),@postion=charindex(@s_str,CONTENT)-1 from hello where id=@id
while @postion>0
begin
updatetext hello.CONTENT @p @postion @rplen @d_str
select @postion=charindex(@s_str,CONTENT)-1 from hello where id=@id
end fetch next from #tb into @id
end
close #tb
deallocate #tb--显示结果
select * from hello--删除数据测试环境
drop table hello