Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Detect hex 0x00 in nvarchar column Expand / Collapse
Author
Message
Posted Tuesday, July 31, 2012 5:41 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, November 27, 2012 9:02 AM
Points: 114, Visits: 140
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
Post #1337807
Posted Tuesday, July 31, 2012 5:58 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 9:07 AM
Points: 1,231, Visits: 9,668
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

Post #1337817
Posted Tuesday, July 31, 2012 6:57 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, November 27, 2012 9:02 AM
Points: 114, Visits: 140
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




Post #1337870
Posted Tuesday, July 31, 2012 7:03 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 9:07 AM
Points: 1,231, Visits: 9,668
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...
Post #1337871
Posted Tuesday, July 31, 2012 7:20 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, November 27, 2012 9:02 AM
Points: 114, Visits: 140
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.

Post #1337890
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse