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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:40:24+00:00 2026-06-12T12:40:24+00:00

I need to create a stored procedure to do the following; SELECT * FROM

  • 0

I need to create a stored procedure to do the following;

    SELECT * FROM TABLE1

Then for each row returned;

    INSERT INTO TABLE2 (column1, column2, column3,...) 
    VALUES (value1, value2, value3,...)

How would I go about doing this?

UPDATE **

So based on responses so far I’ve got the following sql;

INSERT INTO recEntrantStatus (entrantId, roundId, judgeId)
SELECT entrantId, judgeId
FROM recEntrantStatus
WHERE roundId = 0
AND voted = true
AND enterNextround = true

But I need to add a fixed value eg an input @round into the newly created records in the column roundId.

How do I go about doing that?

Thanks.

————————————- UPDATE 2 ——————————————-

So thanks to some significant help from you guys, I’ve now got the following SQL which works great at this stage:

  INSERT INTO recEntrantStatus (entrantId, roundId, judgeId, notified, voted, enterNextRound)
  SELECT entrantId, (@round + 1), judgeId, 0, 0, 0
  FROM recEntrantStatus
  WHERE roundId = @round
  AND voted = 1
  AND enterNextround = 1

This code checks for all records where ‘enterNextRound’ is true, and then creates a new record for each of them.

However, I now need to expand this so that:

A) Check a second table(tblJudges) for all judges and get an array of all the judges Id’s (Id)

B) Do the same as in the above example except now creating each of the above records for each of the judges / judges Id’s obtained from step A.

Any help / suggestions would as always be greatly appreciated.

Thanks!

CLOSED – Question posted as a new question due to additional requirements. 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-12T12:40:25+00:00Added an answer on June 12, 2026 at 12:40 pm
    CREATE PROCEDURE myProcedure
    AS
        INSERT INTO table2 (col1, col2, col3)
        SELECT      col1, col2, col3
        FROM        table1
    GO
    

    Or something similar should work. SQL Server allows you to perform an INSERT directly from a SELECT statement.

    Note that this really doesn’t need to be a stored procedure unless there’s more going in to it (business logic or conditions you want static across all implementations).


    Update

    CREATE PROCEDURE myprocedure @roundId DECIMAL(5,2)
    AS
      INSERT INTO   recEntrantStatus
                   (entrantId, roundId, judgeId)
      SELECT        entrantId, roundId, judgeId
      FROM          recEntrantStatus
      WHERE         roundId = @roundId
        AND         voted = 1
        AND         enterNextRound = 1
    GO 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need create a SQL Server stored procedure that does the following: Take an
I have the following stored procedure ALTER PROCEDURE [dbo].Test AS BEGIN CREATE TABLE ##table
I need to convert the following stored procedure of SQL Server to MySQL. I
I have a stored procedure such as the following: CREATE PROCEDURE procTest -- Add
I am passing a comma-delimited list of values into a stored procedure. I need
I need to create a report using SQL Server 2008R2 Stored procedure that will
I want to do following: Make Oracle stored procedure for read all data from
I need to accomplish the following in the stored procedure: Pass parameterized column names.
I have a dynamic SQL statement I've created in a stored procedure. I need
I need to create a stored proc that will return records (more than one

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.