Insert Picture into SQL Server 2005 Image Field using only SQL
CREATE TABLE Employees
(
Id int,
Name varchar(50) not null,
Photo varbinary(max) not null
)
INSERT INTO Employees (Id, Name, Photo)
SELECT 10, 'John', BulkColumn
FROM Openrowset( Bulk 'C:\photo.bmp', Single_Blob) as EmployeePicture
How to store image in SQL Server database tables column
give this a try,
insert into tableName (ImageColumn)
SELECT BulkColumn
FROM Openrowset( Bulk 'image..Path..here', Single_Blob) as img
INSERTING
REFRESHING THE TABLE
How Do You Save An Image Out of a SQL Database Into the File System Using only SQL?
With SQL 2k8 there is the new FILESTREAM type that covers such cases. Filestreams can be opened via the Win32 file access handle like any other file, but hey are integrated into the database from transaction and backup/restore point of view.
I had a similar issue in SQL 2k5 and my solution was to use a CLR stored procedure with EXTERNAL_ACCESS that was writing into the file system using C# file operations.
Insert image taken from a web url into SQL Server
Download Image from a URL using C#
For using WebClient you might need to include the System.Net namespace.
WebClient wc = new WebClient();
wc.DownloadFile(URL_Of_The_Image, FileName_You_Want_to_Store_It_As);
Upload an Image into SQL Server table using OPENROWSET
CREATE TABLE EmployeeProfile
(
EmpId INT,
EmpName VARCHAR(50) not null,
EmpPhoto VARBINARY(MAX) not null
)
GO
INSERT EmployeeProfile (EmpId, EmpName, EmpPhoto)
SELECT 1001, 'Vadivel', BulkColumn
FROM OPENROWSET( BULK 'C:\Images\Demo.jpg', Single_Blob) AS EmployeePicture
GO
Refer - http://vadivel.blogspot.in/2005/10/saving-images-as-blob-into-sql-server.html
Related Topics
Protecting Against SQL Injection in Python
Spark SQL Queries VS Dataframe Functions
SQL Query to Select Distinct Row with Minimum Value
How to Convert Comma Separated Nvarchar to Table Records in SQL Server 2005
How to Show All Privileges from a User in Oracle
Insert Rows into Multiple Tables in a Single Query, Selecting from an Involved Table
Postgres Dynamic Query Function
Google Spreadsheet "=Query" Join() Equivalent Function
Database Eav Pros/Cons and Alternatives
Calculate a Sum of Type Time Using SQL
Calculate Business Days in Oracle SQL(No Functions or Procedure)
Postgresql Create Table If Not Exists
The Parameterized Query Expects the Parameter Which Was Not Supplied
How to Select from List of Values in Oracle