Update of image columns in triggers

  • I've been trying to add a record to a table with a column having an image data type thru an INSERT trigger of another table. The record is getting added with the primary key information but the image column info is not. I would initially insert a record with just a space on the image column to generate a valid pointer for the column then I used UPDATETEXT to update the information.

    Any help would be appreciated.

  • DECLARE @src_textptr varbinary(16), @dest_textptr varbinary(16);

    SELECT @src_textptr = TEXTPTR( txtfld )

    FROM src_tbl

    WHERE IDENTITYCOL = 1;

    -- Ensure that the text pointer is initialized for the

    -- destination table

    UPDATE dest_tbl

    SET txtfld = ''

    WHERE IDENTITYCOL = 2;

    SELECT @dest_textptr = TEXTPTR( txtfld )

    FROM dest_tbl

    WHERE IDENTITYCOL = 2;

    -- If the source & destination pointers are NOT NULL , do the copy

    -- of the text data from the source table to the destination.

    IF COALESCE( @src_textptr , @dest_textptr ) IS NOT NULL

    UPDATETEXT dest_tbl.txtfld @dest_textptr 0 NULL src_tbl @src_textptr;

    Shrinivas L.K.


    Shrinivas L.K.

Viewing 2 posts - 1 through 1 (of 1 total)

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