!!!题目:::向表booksbuy中添加一个mention列,其数据类型为text.再用writetext向第一行的mention列中添加’this is tsinghua publisher.’怎么写?帮忙下?要可以运行的哦 
 
表:create table newbooksbuy
(BOOKID int identity primary key,
bookname char(50) null,
publisher char(50)  null,
author char(50) not null, 
buyprice float not null,
saleprice float null,
buytime datetime default(getdate()) not null);
  

解决方案 »

  1.   

    alter table booksbuy add column mention text
      

  2.   

    用writetext向第一行的mention列中添加’this is tsinghua publisher.’为什么不用insert into?
      

  3.   


    多了column吧
    alter table newbooksbuy
    add mention text
      

  4.   

    我知道答案了:
    --5、向表booksbuy中添加一个mention列,其数据类型为text.
    --   再用writetext向第一行的mention列中添加’this is tsinghua publisher.’
    --答案:
    alter table booksbuy add mention text null
    go
    sp_tableoption 'booksbuy','text in row','off'
    --EXEC sp_dboption 'pubs', 'select into/bulkcopy', 'true'
    --注意事项:要先向text类型的列中插入数据,否则textptr()查到的指针为null。writetext就无法执行。
    insert into booksbuy values ('SQLserver2000培训教程','清华','余晨',33.00,null,default,'abc')
    go
    select * from booksbuy
    --答案:用writetext写入数据
    begin tran
     declare @ptrval binary(16)
     select @ptrval=textptr(mention)
     from booksbuy
     where bookid=1
     writetext booksbuy.mention @ptrval 'this is tsinghua publisher.'
    --select mention from booksbuy
    commit
    select * from booksbuy