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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:40:59+00:00 2026-06-14T17:40:59+00:00

I am trying to make stored procedure that: – Get list of int rows

  • 0

I am trying to make stored procedure that:
– Get list of int rows

select ItemId from Items -- this returns: 1,2,3,4,5,6
  • In the second part of procedure I have to add row in another table for each of selected number.
    Something like:

    foreach ItemId in previous result
    insert into table (ItemIdInAnotherTable) values (ItemId)

    UPDATE

    I miss one important part from question.
    In another part of procedure when I am inserting selected items in another table need to insert a few more columns. Something like this:

    insert into dbo.ItemsNotificator
    (UserId,ItemId)
    (13879, (select ItemId from Items))

So it’s not one column. Sorry for confusion 🙁

  • 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-14T17:41:00+00:00Added an answer on June 14, 2026 at 5:41 pm

    Edit :
    Assuming that the table [table] already exists, and if User is a constant, then do like so:

    INSERT INTO [table](UserId, ItemIdInAnotherTable) 
       SELECT 13879, ItemId 
       FROM Items;
    

    If UserId comes from another table entirely, you’ll need to figure out what relationship you need between UserId and ItemId. For instance, if all users are linked to all items, then it is:

    INSERT INTO [table](UserId, ItemIdInAnotherTable) 
       SELECT u.UserId, i.ItemId 
       FROM Items i CROSS JOIN Users u;
    

    If table [table] does NOT already exist, then you can use SELECT INTO, and specify a new table name (e.g. a #temp table stored in tempdb)

    SELECT u.UserId, i.ItemId 
       INTO #tmpNewTable
       FROM Items i CROSS JOIN Users u;
    

    The columns in the newly created table will have the names UserId and ItemId and have the same types.

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

Sidebar

Related Questions

I'm trying to write a stored procedure in SQL that will : Make a
I am trying to make one stored procedure only in SQL Server that lets
I am trying to make a stored procedure to clean constraints from a table.
I am trying to create a stored procedure to retrieve rows from my database
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
I'm having a never-ending problem with trying to call a stored procedure from a
I am trying to make a clr stored procedure for a sql 2005 database
This has me seriously stumped. I have a MySQL stored procedure that looks like
I'm Trying to make a long stored procedure a little more manageable, Is it
I'm trying to create a stored procedure that matches buyers and sellers for a

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.