Solved

SQL Cross Join / Stored Proc

Posted on 2009-07-01
1
380 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 143

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Virtual SQL Server 2014 Standard 35 88
Add a step to a system backup job 6 17
SQL Backup Question 2 29
TSQL convert date to string 4 34
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

839 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