February 21, 2006 at 10:30 am
I having some troubles with ASCII 0 on a SP.
Recently one of the requirements of an old vb6 app is to add in a type 'text' column the content of a file.
Now the program was parsing some characters such as " ' " replacing them for " '' ".
But i don't know what to do when i get some null (ASCII 0) character. There is a special code for this character?<
Thanks
February 21, 2006 at 10:35 am
Try this, could probably write it in a loop, bit brute force but should give you what you need:
update
TableName Set ColumnName = '' Where ascii(substring(ColumnName,1,1)) = 0
update
TableName Set ColumnName = left(ColumnName,1) Where ascii(substring(ColumnName,2,1)) = 0
update
TableName Set ColumnName = left(ColumnName,2) Where ascii(substring(ColumnName,3,1)) = 0
update
TableName Set ColumnName = left(ColumnName,3) Where ascii(substring(ColumnName,4,1)) = 0
update
TableName Set ColumnName = left(ColumnName,4) Where ascii(substring(ColumnName,5,1)) = 0
update
TableName Set ColumnName = left(ColumnName,5) Where ascii(substring(ColumnName,6,1)) = 0
update
TableName Set ColumnName = left(ColumnName,6) Where ascii(substring(ColumnName,7,1)) = 0
update
TableName Set ColumnName = left(ColumnName,7) Where ascii(substring(ColumnName,8,1)) = 0
update
TableName Set ColumnName = left(ColumnName,8) Where ascii(substring(ColumnName,9,1)) = 0
update
TableName Set ColumnName = left(ColumnName,9) Where ascii(substring(ColumnName,10,1)) = 0
update
TableName Set ColumnName = left(ColumnName,10) Where ascii(substring(ColumnName,11,1)) = 0
February 21, 2006 at 10:38 am
This is assumming that the null character is trailing, you will most likely need to rework this if the null catcter is anywhere in the string.
February 21, 2006 at 10:42 am
The app is doing an
Exec StoreName 'FineName', FileSize, 'FileContents'
the problem is that FileContents have an ASCII 0 and SQL throws an "Unclosed quotation mark before the character string 'ÿØÿà'". After "ÿØÿà" there is a ASCII character 0
Any Suggestions??
February 21, 2006 at 11:56 am
February 21, 2006 at 2:09 pm
REPLACE (<ColName>, CHAR(0), '')
_____________
Code for TallyGenerator
February 22, 2006 at 5:55 am
Remember that ASCII zero is C's (LPSTR) string terminator character. Sounds as if something is failing to read past it.
February 22, 2006 at 7:50 am
I've solved the issue from the VB side...
I've started to use ADODb.Stream objects... and also I had to change the dolumnd type fom Text to Image (consecuently also I had to change several programs ).
Viewing 8 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy