copy "entire" nText column from TableB to TableA

  • This should be easy, but blast-it "I" can figure it out! And we're not at SQL 2005 yet so varchar[MAX] data types are not an option!!!!

    Simple scenario, I have ...

    [TableA] with

    identity column [IDa]

    nText data type column [nTextA]

    [TableB] with

    identity column [IDb]

    nText data type column [nTextB]

    I want to copy ENTIRE nTextB from TableB

    into nTextA in TableA

    where

    TableA.IDa=55

    and

    TableB.IDb=222

    This is simply copy Field-to-Field ... but it's got me stumped!

    P.S. Both TableA and TableB records already exist so I cannot use the INSERT to move the nText field. It must be a done through an UPDATE like mechanism.

  • Have you looked at UPDATETEXT in Books Online?

  • I think you want WRITETEXT instead of UPDATETEXT since you are replacing all of the ntext data

    I've only tried this in a small test but this worked for me.

    create table tablea (

    nida int,

    ntexta ntext)

    create table tableb (

    nidb int,

    ntextb ntext)

    insert into tablea (nida,ntexta) values (55,'This is tablea data')

    insert into tableb (nidb,ntextb) values (222,'This is tableb data')

    update tableb set ntextb=ntexta

    from tablea where nida = 55


  • update tableb set ntextb=ntexta

    from tablea

    where nida = 55

    and nidb = 222

    _____________
    Code for TallyGenerator

  • Thanks Segiy,

    I must not have copied the last line out of QA when I posted.


Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply