Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6343853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:31:38+00:00 2026-05-24T20:31:38+00:00

I have a table at the moment with columns ( id#(int), picture(varbinary(MAX) ), and

  • 0

I have a table at the moment with columns ( id#(int), picture(varbinary(MAX) ), and I have a folder on my HDD with a ton of pictures. The pictures in the folder are named by the ‘id’ I want to match them with in my table. How can I do this?

Example:

Table Row: id=25166, picture=NULL
25166.jpg
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:31:38+00:00Added an answer on May 24, 2026 at 8:31 pm

    If you need an example which uses just SQL checkout the following:

    It uses a cursor to loop through each of the rows which do not contain image data and for each row found uses the OPENROWSET BULK provider to load the file.

    CREATE TABLE ImageStore
    ( 
    id INT, 
    picture VARBINARY(MAX) NULL
    )
    GO 
    
    INSERT INTO ImageStore (id) VALUES(25166)
    INSERT INTO ImageStore (id) VALUES(25167)
    
    DECLARE @id INT
    DECLARE image_cursor CURSOR FOR 
    SELECT id FROM ImageStore WHERE picture IS NULL
    
    OPEN image_cursor;
    
    FETCH NEXT FROM image_cursor 
    INTO @id;
    
    WHILE @@FETCH_STATUS = 0
    BEGIN
        DECLARE @sql NVARCHAR(MAX)
    
        DECLARE @imagePath NVARCHAR(255)
        SET @imagePath = 'C:\' + RTRIM(LTRIM(STR(@id))) + '.gif'
    
        SET @sql = 'UPDATE ImageStore '
        SET @sql = @sql + 'SET picture = (SELECT BulkColumn FROM OPENROWSET( BULK ''' + @imagePath + ''', Single_Blob) AS picture) '
        SET @sql = @sql + 'WHERE id = ' + STR(@id)
    
        BEGIN TRY
            EXECUTE sp_executesql @sql 
        END TRY
        BEGIN CATCH
    
        END CATCH   
    
        FETCH NEXT FROM image_cursor 
        INTO @id;
    END
    CLOSE image_cursor;
    DEALLOCATE image_cursor;
    
    SELECT * FROM ImageStore
    
    DROP TABLE ImageStore
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table with 3 columns A B C. I want to select *
At the moment I want to have three columns in my database for Notes:
I have a database containing a single huge table. At the moment a query
i have table structure with 3 colums (column1, column2, column3) and i want to
I have a table whose columns indicate a property of data items. Each item
I have a table that has several columns: HarvestID, HarvestDate, UserID to mention the
I have a simple MySQL query that selects all columns from the table based
I have table GeoIP with three columns: bigint Start, bigint End and varchar Country
Basically I have two models: User and Godfather. The godfather table has three columns:
I've got a CSV file with 11 columns and I have a MySQL table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.