1

I want to insert a .jpg image into SQL server using simple INSERT query.

I tried the following query in which was posted as an answer to the following question Insert Picture into SQL Server 2005 Image Field using only SQL

In my case I modified the query as follows

INSERT INTO iffcar
                      (name, address, idno, barcode, Photo)
SELECT     'ishan', 'hohn', 100, 'barcodedmessage', BulkColumn
FROM         OPENROWSET(BULK 'c:\use.jpg', Single_Blob) AS iffcarPicture

now I am getting the error as

enter image description here

My table structure is as follows

enter image description here

Please help me to resolve the error.

Community
  • 1
  • 1
Ishan
  • 4,008
  • 32
  • 90
  • 153

2 Answers2

1

From this MSSQL tip:

The BULK option was added to T-SQL in SQL Server 2005 and it persists in SQL Server 2008. When using SQL Server 2000 it was possible to read and write to the file system using the sp_OA_Create and sp_OA_Method extended stored procedures.

devio
  • 36,858
  • 7
  • 80
  • 143
0

When i run this on my local server defining the photo as Varbinary(max) it works, when i define it as Varbinary(500) it get an Error, did you define it in your Create statement as Varbinary(500)? try using the same definition form the question you linked, and add the Columns you need in addition.

CloudyMarble
  • 36,908
  • 70
  • 97
  • 130