Hello I need simple script help.
How do I read file (imagefile on filesystem) from file and save it to database binary field (SQL2008 table)?
Hello I need simple script help.
How do I read file (imagefile on filesystem) from file and save it to database binary field (SQL2008 table)?
You 'd better publish your code next time. It's a INSERT INTO and SELECT statement, and we use a special form of the OPENROWSET function to get the image into your table field
'create table first
create table #Images (doclen bigint, doc varbinary(max))
'insert a file
insert into #Images
select len(bulkcolumn), *
from
openrowset(bulk 'C:\images\image1.jpg', SINGLE_BLOB) as r
Also see these answers
http://stackoverflow.com/questions/7509384/insert-image-into-sql-server-2008-express-database-without-front-end-application
http://stackoverflow.com/questions/416881/insert-picture-into-sql-server-2005-image-field-using-only-sql
http://stackoverflow.com/questions/2427767/how-to-store-and-retrieve-images-using-sql-server-server-management-studio