如何在 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
提问by VINNUSAURUS
I Have a table named FEMALE
in my database. It has ID
as Primary Key
, it has an Image
column.
FEMALE
我的数据库中有一个表。它有ID
as 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
插入
REFRESHING THE TABLE
刷新表格
回答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.
您还需要管理员权限才能运行查询。