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

  • Home
  • SEARCH
  • 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 6886391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:45:12+00:00 2026-05-27T05:45:12+00:00

I need to insert into a simple table with two columns. The first column

  • 0

I need to insert into a simple table with two columns.

The first column has to contain the same value from row to row, while the second has to hold the various values from a source table. So it all should look like this:

enter image description here

Question is – is there a way to make a set-based insert in this case? The way I do it now is simply iterate through the rows of the source table. Or it’s also possible to use cursors, only I’m not sure which is best.

But still this is iteration.

Any means to get around this?
Thanks in advance!

  • 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-27T05:45:12+00:00Added an answer on May 27, 2026 at 5:45 am

    If you know your static value ahead of time, you could do something like this:

    INSERT INTO targetTable(Col1, Col2)
    SELECT 1, yourColumn
    FROM sourceTable
    WHERE <condition>
    

    This is assuming that 1 is your static value. It can be replaced with the real value, or a variable, depending on the specifics of your query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to insert records into a table that has no primary key using
I have two tables, both with the same columns. The first table contains original
I have an EAV table (simple key/value in every row) and I need to
I am using sqlite with python. When i insert into table A i need
I need to insert data from table1 into table2. However, I would like to
I need to insert about 1.8 million rows from a CSV file into a
now i need to insert some data from the sqlserver into a word,i know
I plan to insert about 100 million rows into my simple db table where
I need to do 2 query. Basically it's a mysql_query(INSERT INTO table ($value1,$value2)); and
I'm looking to transfer some data from a multi-million row table into another 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.