Using Ms SQL Server 2005 and Management Studio how do I insert a picture into an Image type field of a table?
Most importantly how do I verify if it is there?
views:
12403answers:
6This might solve your problem.
As to verifying that it's there - you may have to write a small app that takes an id value and then goes and retrieves the image.
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
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:\Image1.jpg', Single_Blob) as EmployeePicture
This Sql Query Working Fine...........Prasanna Yelsangikar
For updating a record:
UPDATE Employees SET [Photo] = (SELECT MyImage.* from Openrowset(Bulk 'C:\photo.bmp', Single_Blob) MyImage) where Id = 10
Notes:
- Make sure to add the 'BULKADMIN' Role Permissions for the login you are using.
- Paths are not pointing to your computer when using SQL Server Management Studio. If you start SSMS on your local machine and connect to a SQL Server instance on server X, the file C:\photo.bmp will point to hard drive C: on server X, not your machine!
this is really really cool man... i can't believe its working.. i was looking for this allover man...thnx a lot man...
this is soooooooooooo simple and i was soo confused abt it all these days..reallly thnx a lot man