相关疑难解决方法(0)

将十六进制字符串值插入sql server图像字段会追加额外的0

有一个图像字段,并希望从十六进制字符串中插入:

insert into imageTable(imageField) 
values(convert(image, 0x3C3F78...))
Run Code Online (Sandbox Code Playgroud)

但是当我运行select时,返回值为0,另外0为0x03C3F78 ...

这个额外的0导致另一个应用程序出现问题,我不想要它.

如何阻止添加额外的0?

架构是:

CREATE TABLE [dbo].[templates](
    [templateId] [int] IDENTITY(1,1) NOT NULL,
    [templateName] [nvarchar](50) NOT NULL,
    [templateBody] [image] NOT NULL,
    [templateType] [int] NULL)
Run Code Online (Sandbox Code Playgroud)

并且查询是:

insert into templates(templateName, templateBody, templateType) 
values('I love stackoverflow', convert(image, 0x3C3F786D6C2076657273696F6E3D.......), 2)
Run Code Online (Sandbox Code Playgroud)

实际的十六进制字符串非常大,可以在这里发布.

t-sql binary sql-server-2008

13
推荐指数
2
解决办法
2万
查看次数

标签 统计

binary ×1

sql-server-2008 ×1

t-sql ×1