如何在 SQL Server 数据库表列中存储图像

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15659835/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 14:29:56  来源:igfitidea点击:

How to store image in SQL Server database tables column

sqlsql-serverimagetsql

提问by VINNUSAURUS

I Have a table named FEMALEin my database. It has IDas Primary Key, it has an Imagecolumn.

FEMALE我的数据库中有一个表。它有IDas Primary Key,它有一Image列。

My Question is how do I store an image using a SQL Query?

我的问题是如何使用 SQL 查询存储图像?

回答by John Woo

give this a try,

试试这个,

insert into tableName (ImageColumn) 
SELECT BulkColumn 
FROM Openrowset( Bulk 'image..Path..here', Single_Blob) as img


INSERTING

插入

enter image description here

在此处输入图片说明

REFRESHING THE TABLE

刷新表格

enter image description here

在此处输入图片说明

回答by VINNUSAURUS

Insert Into FEMALE(ID, Image)
Select '1', BulkColumn 
from Openrowset (Bulk 'D:\thepathofimage.jpg', Single_Blob) as Image

You will also need admin rights to run the query.

您还需要管理员权限才能运行查询。