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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:23:18+00:00 2026-06-07T08:23:18+00:00

A little hard to explain in SQL terms because I am using an in-house

  • 0

A little hard to explain in SQL terms because I am using an in-house technology but Let’s say I have an array of a structs (similar to structs we have in C#, C++, etc) and I want to insert its values in a table.
So one way is a psedu-code that iterates through the array, read the fields of the structs and inserts them into the table like this:

for int i =1 to array.Lenght
{
    insert into MyTable values
    {
       MyTable.Field1 = array[i].Field1;
       //etc ...
    }
}

but this is bad, because of performnce. If array has ten elements we are calling insert method ten times.
There should be a brillinat way of doing this with just one insert, somehow using JOINS on table and just call insert one time, But I can’t imagine how to do that…

Any thoughts on this are welcome.

Thanks.

  • 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-06-07T08:23:19+00:00Added an answer on June 7, 2026 at 8:23 am

    This makes sure the query is executed once. This is just an idea, avoiding multiple call insert

    @sql = 'insert into mytable(col_1) values'
    for int i =1 to array.Lenght
    {
       if(i > 1)
        @sql = ',('+@sql + array[i].Field1+')'
       else
        @sql = '('+@sql + array[i].Field1+')'
    }
    @sql = @sql + ';'
    exec @sql
    

    Script looks like

     insert into mytable(col_1) values
     (1),(2),(3);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a little hard to explain, but I have an HTML table, full
I have a problem that is a little hard to explain. I am building
Greetings Guru's, This is a little hard to explain, but I'll give it a
This a little hard for me to explain, but I'll try my best. I'm
I know the title is a little off, but it's hard to explain the
It is a little hard to explain it with my poor english but i
This is a little hard to explain.. I am using tomcat 6.0 to test
I know the title makes little sense, mostly because it's hard to explain in
Ok this is a little hard to explain but here I go. On View1
It's a little hard to explain what I need but i'll try: I need

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.