?
Solved

SQL Cross Join / Stored Proc

Posted on 2009-07-01
1
Medium Priority
?
399 Views
Last Modified: 2012-05-07
I want to create a stored procedure that will take in a year, look up "active" rows in a "Code Table" and insert it into another table (Table B).  For instance:

Year: 2009

Code Table
ID - several other columns - Status
1 - ... - Active
2 - ... - Inactive
3 - ... - Active

Table B
Year - ID
2009 - 1
2009 - 3
0
Comment
Question by:mmeisel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 24757734
this should do:
create procedure yourproc @year int
as
  insert into table_b ( [year], ID )
   select @year, ID 
     from code_table

Open in new window

0

Featured Post

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question