How do insert many images (BLOB) into a SQL Server table

Tags:
BLOB
SQL
T-SQL
How do I insert several images (BLOB) in to a SQL Server table?


Software/Hardware used:
SQL Server 2008
1

Answer Wiki

Thanks. We'll let you know when a new response is added.
insert into tableName (ImageColumn) 
SELECT BulkColumn 
FROM Openrowset( Bulk ‘image..Path..here’, Single_Blob) as img 

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • reckonankit
    Hey you can easily insert several images in SQL single column

    This shows one way to import multiple files where the filenames can be calculated:

    declare @Count as Int = 3622;
    declare @Filename as VarChar(128);
    declare @Statement as VarChar(256)
    
    while @Count <= 3625
      begin
      set @Filename = 'C:\Photos\IMG_' + Right( '000' + Cast( @Count as VarChar(5) ), 4 ) + '.JPG';
      set @Statement = 'select * from OpenRowSet( Bulk ''' + @Filename + ''', Single_Blob ) as Nought';
      execute( @Statement )
      set @Count = @Count + 1;
      end;

    3,295 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: