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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:14:12+00:00 2026-05-23T06:14:12+00:00

Is there a quick way to insert multiple values into one column while the

  • 0

Is there a quick way to insert multiple values into one column while the second column has a different value.

Say I have two columns called Number and Colour. The Number column is always going to be 1 and the Colour column changes.

At the moment i’m doing the following…

INSERT INTO ColourTable(Number, Colour)

SELECT '1' ,'red'

UNION ALL

SELECT '1' ,'yellow'

UNION ALL

SELECT '1' ,'green'

UNION ALL

SELECT '1' ,'blue'

UNION ALL

SELECT '1' ,'orange'

Which is fine if there are just a few inserts to do but the problem is I need to insert about 100 rows with the colour column changing and I was wondering if there was a way to set the number column?

**i think i need to explain myself a little better…

say the colour columns have 40 different colours i need to insert these colours into different rows with the number column saying say 1 to 100 (the number are actually randon codes so incrementing won’t work).

So I have to do 40 inserts of the colour rows with the column number = 1
40 inserts with the column number = 2
40 inserts with the column number = 3 and so on to 100

  • 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-23T06:14:13+00:00Added an answer on May 23, 2026 at 6:14 am

    If I’m understanding the question correctly then you’re looking for all combinations of your random code field and colour field.

    So for example if you had three colours red, green and blue and 3 random codes 1, 14, 25 then you’d like the following set.

    1   red
    1   green
    1   blue
    14  red
    14  green
    14  blue
    25  red
    25  green
    25  blue
    

    If this is the case then you could produce a pair of tables, one with the codes, the other with the colours

    CREATE TABLE #Codes(
        [CodeNumber] int NOT NULL
    ) 
    
    Insert Into #Codes 
    Select 1
    Union All
    Select 14
    Union All
    Select 25
    
    
    
    CREATE TABLE #Colours(
        [Colour] varchar(50) NOT NULL
    ) 
    
    Insert Into #Colours 
    Select 'red'
    Union All
    Select 'green'
    Union All
    Select 'blue'
    

    Then use a cross join to return all of the combinations.

    Select cd.CodeNumber, cl.Colour
    From #Codes cd
        Cross Join #Colours cl
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a quick way to combine one arrays values as the other array's
Is there a quick and easy way of telling if a table has changed
Does anyone know of a quick way to have NHibernate insert default values for
Is there a quick way to join paths like the Join-Path function in Powershell?
Is there a quick way to find every match of a regular expression in
is there a quick way to sort the items of a select element? Or
Is there a quick way to detect classes in my application that are never
Is there a quick way to set an HTML text input ( <input type=text
Is there a quick way to determine whether you are using certain namespaces in
In Spring 2.0, is there a quick way to have a list of the

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.