SQL Server 2008 ---- 更新大值數據類型的列

在 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:表示要覆蓋部分的長度

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章