October 24, 2011 at 3:19 am
Hi, I've got a problem with importing file. My web application store users files as data type image. I would like to create procedure to automatically store xml files in users accounts.
this is my procedure to import file:
SET @SqlUpd=' UPDATE OrderAttachments
SET Attachment = (SELECT * FROM OPENROWSET(BULK ''' + @fname + ''',
SINGLE_BLOB) AS imagesource) WHERE [Filename] = ''' + @fnameXML + ''' '
exec (@SqlUpd)
it is working, but when I download file from web page, file is shorter by one byte - last byte in HEX view - 00.
Users cannot import xml's because of error
When I open this file in notepad and save it to new one, everything is ok
please help
October 25, 2011 at 2:32 pm
When the Attachment column was created, the ANSI_PADDING setting was most likely 'OFF'. This causes trailing blanks to be automatically trimmed from varchar and nvarchar columns. The same thing happens with 0x00 bytes at the end of varbinary or image columns.
The solution is to create a column after setting ANSI_PADDING ON. I do not believe that setting can be changed for a column, but I may be wrong about that.
Please note that is is possible to have columns with ANSI padding and columns without ANSI padding coexistent in a table.
The sys.columns view has a column, 'is_ansi_padded', which will inform you as to the ANSI_PADDING state at the time the column was created.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply