Germstorm Germstorm - 6 months ago 18
SQL Question

Insert Picture into SQL Server 2005 Image Field using only SQL

Using SQL Server 2005 and Management Studio how do I insert a picture into an

Image
type column of a table?

Most importantly how do I verify if it is there?

Answer
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