Solved

SQL Cross Join / Stored Proc

Posted on 2009-07-01
1
348 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
1 Comment
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now