Detect hex 0x00 in nvarchar column

  • Hi, this is my first post

    I have a 3rd party adapter in SSIS - which gives an error "'.', hexadecimal value 0x00, is an invalid character. Line 1, position 234.". - but only when importing a particular column, so it must be something to do with the data in that column.

    How can I construct a query to identify rows which contain a hex 0x00 character. Note no rows contain NULL, and most rows contain over 1000 characters in the nvarchar(MAX) column that is giving the error.

    Thanks in advance for any advice

  • I did a bit of playing around and couldn't get it to work reliably with LIKE, but this worked ok with CHARINDEX:

    SELECT acolumn FROM #atable WHERE CHARINDEX(NCHAR(0),acolumn)!=0

  • Thank-you

    Your code has helped me establish that a rogue hex 0x00 is not the cause of the original error. I'll raise it with the 3rd party supplier - the string however does contain cyrillic and accented characters, and possibly some Japanese - so I'm currently using the binary chop method to isolate the offending rows.

    Incidentally - when trying to create some test data, I found it is quite hard to put a hex 0x00 into a string - does SQL Server use that character as a string terminator?

    Compare the results of these two

    SELECT 'value' + char(0) + 'more value'

    SELECT 'value' + char(65) + 'more value'

    The first is cut off at the char(0) character

  • Why don't you just set the SSIS package to redirect the error rows in the data flow and dump them back out to a table or file to determine which row's the culprit?

    For both Unicode (UTF-8) and ASCII, 0 is defined as "NUL", which looks like a non-display character that's used as a terminator of some sort, so I'm sure it would cause issues with display...

  • Just getting to grips with SSIS.

    Redirecting error rows helped

    I have now found a new error: "Could not retrieve data for column Content. Error is The value is too large to fit in the column data area of the buffer.".

    But the data seemed to import anyway - I'm now checking to see if anything is truncated, but in a first pass the import seems to have worked.

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

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