Home Forums SQL Server 2005 T-SQL (SS2K5) Inserting binary string at an offset to exsting data in a Text type field RE: Inserting binary string at an offset to exsting data in a Text type field

  • Am trying this...

    -- Use a table variable to cast the trace

    -- header from image to varbinary(max)

    DECLARE @header TABLE (

    header varbinary(max)

    )

    -- insert the trace header into the table

    INSERT INTO @header

    SELECT AD.SW_GEOMETRY

    FROM Abstract_DPB AD

    WHERE AD.SW_MEMBER=40967

    -- update the byte at offset 390 with version 10 (SQLServer 2008)

    -- instead of version 11 (SQLServer 2012)

    UPDATE @header

    SET header = STUFF(header,10,0,CONVERT(varbinary(max),0x103000000010000000))

    -- write the header back to the trace table

    UPDATE Abstract_DPB

    SET SW_GEOMETRY = (SELECT header FROM @header)

    WHERE SW_MEMBER=40967

    but getting this error... "SQL.sql: Error (36,1): Implicit conversion from data type varchar(max) to varbinary(max) is not allowed. Use the CONVERT function to run this query."

    I've added the convert in the update above..?