您的位置:首页 > 数据库

SQL Server 2008 ---- 更新大值数据类型的列

2014-06-29 21:35 309 查看
在 SQL Server 2008 中引入了 varchar(max),nvarchar(max),varbinary(max) ....等数据类型,用来代替 text,ntext,image 这些数据类型。
varchar(max),nvarchar(max),varbinary(max)这些数据类型的插入还是与别的数据类型是一样的,可是更新就有一些不同了。下面看例子。
定义表:

create table T_test( ID int not null,String varchar(max));
插入数据:

insert into T_test(ID,String) values(1,'At the begging of each chapter you will notice that basic concepts are covered first');
更新数据:

update T_test
set String.write('In addtion to the basic ,this chapter will also provid recipes that can be used in your day to day development and administration',null,null)
where T_test.ID=1;
总结:SQL Server 2008 中可以用 列名.方法名(参数1,参数2,。。。) 的方式来更新大数据的值。可以看出这里的SET后面没有‘=’号,要记好了。下面是Write 方法的原型
.write(expression,@offset,@length) expression:表示要存入的文本块、@offset:表示新文本块在老数据块中的起始位置。@length:表示要覆盖部分的长度
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息