Insert hex string value to sql server image field is appending extra 0
Posted
by rotary_engine
on Stack Overflow
See other posts from Stack Overflow
or by rotary_engine
Published on 2010-04-17T09:33:09Z
Indexed on
2010/04/17
11:03 UTC
Read the original article
Hit count: 236
sql-server-2008
Have an image field and want to insert into this from a hex string:
insert into imageTable(imageField)
values(convert(image, 0x3C3F78...))
however when I run select the value is return with an extra 0 as 0x03C3F78...
This extra 0 is causing a problem in another application, I dont want it.
How to stop the extra 0 being added?
The schema is:
CREATE TABLE [dbo].[templates](
[templateId] [int] IDENTITY(1,1) NOT NULL,
[templateName] [nvarchar](50) NOT NULL,
[templateBody] [image] NOT NULL,
[templateType] [int] NULL)
and the query is:
insert into templates(templateName, templateBody, templateType)
values('I love stackoverflow', convert(image, 0x3C3F786D6C2076657273696F6E3D.......), 2)
the actual hex string is quite large to post here.
© Stack Overflow or respective owner