I am banging my head against a problem that I am sure shouldnt be as tricky as I am making it feel ...
I have an XML source that I am using XQuery to shred out values. One of these values is a BINARY value that is within the XML as a varchar. I am taking the 5 values into a table variable and then want to use the 'BINARY' column in a join. This works ...
DECLARE @bin VARBINARY(64)
DECLARE @bin2 VARBINARY(64)
DECLARE @char VARCHAR(64)
SET @bin = 0x020000008A596A10BA403E299E0BF0EE0D22976C53F6AA06
SELECT CONVERT(VARCHAR(64), @bin, 2)
SELECT @char = CONVERT(VARCHAR(64), @bin, 2)
SET @bin2 = CONVERT(VARBINARY(64), @char, 2)
I am able to take a BINARY value, store it as a VARCHAR and then return it to a BINARY value without issue. However when I try to apply this to my 'live' work it errors.
This code section produces the same error
DECLARE @Table TABLE
INSERT INTO @Table
( Bin_Values )
VALUES ( '0x020000008A596A10BA403E299E0BF0EE0D22976C53F6AA06' ),
( '0x02000000EE634318A5EB0A72DD794F2223EC572324253446' )
SELECT [t].[Bin_Values] ,
CONVERT(VARBINARY(64), [t].[Bin_Values], 2)
FROM @Table AS t
I cannot get past the error to varbinary.
Msg 8114, Level 16, State 5, Line 11
Error converting data type varchar to varbinary.
Can anyone help me out please?
Jun 03 '11 at 04:35 AM