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 3234872
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:26:30+00:00 2026-05-17T17:26:30+00:00

I need to insert about 500 images to database at once. I have a

  • 0

I need to insert about 500 images to database
at once.
I have a script, that builds multiple query script:

SELECT 'INSERT INTO [truvle].[dbo].[Ads_Images]([Img_adId],[Img_image]) 
     SELECT CONVERT(INT, ' + CAST([Ad_id] AS VARCHAR) + ')' +
   ',(SELECT * FROM OPENROWSET(BULK N''' +  [Ad_path] + ''', SINGLE_BLOB) as [something]) GO'
  FROM [truvle].[dbo].[Ads]

In result I get 500 “insert” queries like these:

…

INSERT INTO [truvle].[dbo].[Ads_Images]([Img_adId],[Img_image])        
SELECT CONVERT(INT, 1),(SELECT * FROM OPENROWSET(BULK N'some_path/Banners/58097048.gif', SINGLE_BLOB) as [something]) 
GO

INSERT INTO [truvle].[dbo].[Ads_Images]([Img_adId],[Img_image])        
SELECT CONVERT(INT, 2),(SELECT * FROM OPENROWSET(BULK N'some_path/Banners/10404012.gif', SINGLE_BLOB) as [something]) GO

INSERT INTO [truvle].[dbo].[Ads_Images]([Img_adId],[Img_image])        
SELECT CONVERT(INT, 3),(SELECT * FROM OPENROWSET(BULK N'some_path/Banners/10398875.gif', SINGLE_BLOB) as [something]) GO

…

But when I run this script and there is some error in some single query (file doesn’t exists, for example) script stops working,
so I have to remove wrong row and run it again.
Does exist some way to skip defective query and keep whole script running?

Thanks,
Katy.

  • 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-17T17:26:30+00:00Added an answer on May 17, 2026 at 5:26 pm

    Check if this helps. You can add this before each of your bulk insert statements-

    DECLARE @doesExist INT
    
    SET NOCOUNT ON
    EXEC xp_fileexist 'C:\test.txt', @doesExist OUTPUT
    SET NOCOUNT OFF
    
    IF @doesExist = 1
    BEGIN
    BULK INSERT Test FROM 'C:\test.txt'
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to insert about 1.8 million rows from a CSV file into a
I need to insert records into a table that has no primary key using
I want to bulk insert about 700 records into the Android database on my
I have data containing about 30 000 records. And I need to insert this
I have a database in which I need to insert batches of data (around
Using JDBC (Oracle) I need to insert about thousand rows into each of two
I need and advice about MySQL. I have a user table that have id,
I need to insert UIElements into a Grid that does not get generated until
I have a binary file that I need to insert a header at the
I need to perform update/insert simultaneously changing structure of incoming data. Think about Shops

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.