Ascii code spaces

  • Hi we are experiencing difficulties importing data into sql. We are handling data from an excel file through asp.net technology into a sql table.

    The problem is there is no match between the imported data and the article codes in our database.

    Following select statements

    select ascii(substring('PETESHT WBK015',8,1))

    select ascii(substring('PETESHT WBK015',8,1))

    are giving this result :

    160

    32

    How can this be and how can it be solved ?

    Can this be converted through an update statement

    thx in advance.


    JV

  • Both SELECT statements are the same and return 32? Well this is the case on my Server.

    What exactly are you trying to do? Remove the spaces or are the 2 different ascii codes giving you the issue with the import? If the is the case, you could try to cast the string into a specific type on the ASP.Net side or replace the strings there before importing?

    This can be a case that once string is type varchar and the other nvarcahr (unicode). Try casting them in the SQL statement too:

    select ascii(substring(cast('PETESHT WBK015' as varchar),8,1))

    select ascii(substring(cast('PETESHT WBK015' as varchar),8,1))

    Hope I was not totally off.

    Pierre

  • ascii code 160 is a non-breaking space. it is different than a normal space (ascii code 32). it's used a lot in html [& nbsp ;]

    if they're causing problems in your data, then the app that's entering them should filter them out or you can use the replace function like so: text = replace(text, char(160),char(32))

  • many thanx !!


    JV

  • Thank you. Perfect!!!

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

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