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.

3
  • What is your photo Column defined as? can you provide the table create stmt? Commented May 10, 2011 at 11:49
  • 2
    Are you definitely on SQL Server 2005 not SQL Server 2000? Enterprise Manager is a 2000 tool. Commented May 10, 2011 at 13:29
  • @ Martin Very sorry very very sorry, it is not 2005 but 2000 Commented May 10, 2011 at 16:29

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.