从sql查询分析器在varbinary插入图像 [英] inserting image at varbinary from sql query analyzer

查看:94
本文介绍了从sql查询分析器在varbinary插入图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想从SQL查询分析器插入图像时,这是我的错误.

This is my error when I wanted to insert image from SQL query analyzer.

Disallowed implicit conversion from data type varchar to data type varbinary, table 'Northwind.dbo.files', column 'filecontent'. Use the CONVERT function to run this query.


我的查询是


My queries are

Create table files(autoid int, filename varchar(50), filecontent image, isactive varchar(50))

insert into files(autoid,filename,filecontent,isactive) values(12,'google','C:\jtsimg.jpg','yes')

select * from files



请帮助我解决此错误.
预先感谢亲爱的朋友.



Please help me to solve this error.
Thanks in advance dear friends.

推荐答案

filecontent字段应包含二进制文件,而不是图像文件的路径.插入期间此转换失败.
您不能直接通过Management Studio进行此操作.
而是尝试
The filecontent field should contain the binary file and not the path to the image file. This conversion fails during the insert.
You cant do this directly via management studio.
Instead try
insert into files(autoid,filename,filecontent,isactive) 
SELECT 12, ''google'', BulkColumn 
FROM Openrowset( Bulk ''C:\jtsimg.jpg'', Single_Blob) as pic, ''yes''


请尝试一下

Try this please

insert into files(autoid,filename,isactive,filecontent)
select 1 ,'test file name' ,'no',*
from openrowset (Bulk 'C:\bala.jpg',single_blob) as image


这篇关于从sql查询分析器在varbinary插入图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆