Storing Images in Database

  • Hi,

    I want to store Images as binary data in SQL table and compare it each time with a image file I am getting.

    I've tried below approach but getting error:

    DROP TABLE #BLOBTest

    CREATE TABLE #BLOBTest

    (

    TestID int IDENTITY(1,1),

    BLOBName varChar(50),

    BLOBData varBinary(MAX)

    );

    INSERT INTO #BLOBTest

    (BLOBName, BLOBData)

    SELECT 'First test file',

    BulkColumn FROM OPENROWSET(

    Bulk 'C:\Files\12656.jpg', SINGLE_BLOB) AS BLOB

    Error: Msg 4861, Level 16, State 1, Line 10

    Cannot bulk load because the file "C:\Files\12656.jpg" could not be opened. Operating system error code 3(failed to retrieve text for this error. Reason: 15105).

    Please help.

    ____________________________________________________________

    AP
  • The error 3 indicates a lack of ntfs permissions on the file location.

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • I have given all permissions, still same issue.

    Is there any other way we can store images as binary in SQL table?

    ____________________________________________________________

    AP
  • Anshul Parmar (2/26/2015)


    I have given all permissions, still same issue.

    Full permission to who??

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • the file must exist on the server, unless you explicitly call a unc path like \\servername\c$\Files\12656.jpg

    even then, the service account that SQL runs under must be the one with permissions to wherever the file exists...not YOU.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply