liuhongyu 发表于 2018-10-17 11:02:28

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(>  插入数据:
  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:表示要覆盖部分的长度。

页: [1]
查看完整版本: SQL Server 2008 ---- 更新大值数据类型的列