Inserting pictures into Image type columns can be a perplexing task, especially if you want to use only SQL statements.
To effectively insert a picture into an Image field in SQL Server 2005, follow these steps:
Create the Database Table:
CREATE TABLE Employees ( Id int, Name varchar(50) not null, Photo varbinary(max) not null )
Insert the Picture:
INSERT INTO Employees (Id, Name, Photo) SELECT 10, 'John', BulkColumn FROM Openrowset( Bulk 'C:\photo.bmp', Single_Blob) as EmployeePicture
Verifying Insertion:
Alternatively, you can use the following SQL query:
SELECT Name, Photo FROM Employees WHERE ID = 10
The above is the detailed content of How to Insert Pictures into Image Fields in SQL Server 2005 Using SQL Statements?. For more information, please follow other related articles on the PHP Chinese website!