Table : FileData
Column Datatype ------ -------- FiledataId int Value nvarchar(max)
In the Value column, I put file name of file+|+ binary of File.
Example:
- Image example data: helloWorld.png|/9j/4AAQSkZJRgABAgAAAQAB.....
- File example data:
3_Templateexcel.xlsx|UEsDBBQABgAIAAAAIQCnlfmZhAEAABQGAAATAN0BW0NvbnRlbnRfV
Now, I would like to make a new table: Table : FileDataNew
Column Datatype ------ -------- FileDataId int Name nvarchar(255) Value Image
I would like to move data from FileData table to FileDataNew. But I have a problem when converting nvarchar data to image Field.
I tried solutions:
Solution one:
cast(cast(filedata as binary) as varchar(1000))Solution two :
convert (convert (varchar(max) , convert (varbinary (max) , filedata ))BUT it still DOES NOT work.
Is it possible to convert nvarchar data (/9j/4AAQSkZJRgABAgAAAQAB..... Or UEsDBBQABgAIAAAAIQCnlfmZhAEAABQGAAATA)
to image field, and keep it still working?
Can you give me any ideas?
Thanks.