Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored Procedure Help 1

Status
Not open for further replies.

TanmedIT

IS-IT--Management
Nov 6, 2000
53
0
0
US
I first apologize if this is in the wrong forum. I am new to SQL and I have a stored procedure question. I have 2 tables that I need to combine into one temp table.

Table One (Distributor Information): DistributorID

Tables Two (Item Information): Item Number, Class ID

I need to create a tables that will include all the item numbers and classid based on any criteria I choose (I can do the WHERE clause of the SQL statement) and then also have the distributorID in each record.

For instance:

DistributorID Item Number ClassID
101 STA-P1 Nexa
101 STA-P2 Nexa
101 STA-P3 Nexa
101 STA-P4 Nexa
102 STA-P1 Nexa
102 STA-P2 Nexa
102 STA-P3 Nexa
102 STA-P4 Nexa
103 STA-P1 Nexa
103 STA-P2 Nexa
103 STA-P3 Nexa
103 STA-P4 Nexa

I am not real sure how to do this and there is no fields that I can join the tables with. Any Idea?

Thanks in advance
 
Take a look at normalization in BOL; without a common field (foreign key), you will be unable to join the tables.

Alcohol and calculus don't mix, so don't drink and derive.
 
I understand this, but can't I create a temp tables with these headings, then populate it with some kind of "do while" or something to that effect. I know it can be done, i am just not sure how to do it. I remember doing something like this with "C" programming back in college, but that was almost 10 years ago and this is not C programming I am doing.

Thanks
 
Code:
Select *
From   [Distributor information]
       Cross Join [item information]

ONLY RUN THIS IF YOU HAVE SMALL TABLES!

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top