Wie füge ich unter Verwendung von SQL Server 2005 und Management Studio ein Bild in eine Spalte vom Typ Image
einer Tabelle ein?
Am wichtigsten ist, wie überprüfe ich, ob es da ist?
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
So aktualisieren Sie einen Datensatz:
UPDATE Employees SET [Photo] = (SELECT
MyImage.* from Openrowset(Bulk
'C:\photo.bmp', Single_Blob) MyImage)
where Id = 10
Anmerkungen:
Tabelle erstellen:
Create Table EmployeeProfile (
EmpId int,
EmpName varchar(50) not null,
EmpPhoto varbinary(max) not null )
Go
Anweisung einfügen:
Insert EmployeeProfile
(EmpId, EmpName, EmpPhoto)
Select 1001, 'Vadivel', BulkColumn
from Openrowset( Bulk 'C:\Image1.jpg', Single_Blob) as EmployeePicture
Diese SQL-Abfrage funktioniert einwandfrei.