Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Trying to join data

Author  Topic 

hardcoded
Starting Member

1 Post

Posted - 2009-07-30 : 16:48:01
I have a mess on my hands. There are 3 tables that should've been linked (in an asp app) via primary key. Instead there was an issue and now that link is broken. I'm trying to find the best way to reconnect these tables and need some assistance.

The issue is that the first table has 5 columns for data. For any that is filled in, that data is sent to table2 in a new entry. So if a user makes an entry in table1 with all 5 filled in, they will have 5 records in table2.

Here is what they do have in common:

Table1
UserID
Month
Year
Input1
Input2
Input3
Input4
Input5

Table2
UserID
Month
Year
Input[1-5]

Table3
UserID
Month
Year
Input[1-5]

The problem is that there can be multiple entries in table1 for the month/year combination for one user, so I can't simply join on that criteria.

winterh
Posting Yak Master

127 Posts

Posted - 2009-09-16 : 07:11:33
use temporary tables

I would use a temporary table for everything ever
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2009-09-16 : 07:43:48
Please post proper sample data.Hv a look at the link below on hw to do this.

http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

PBUH
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-09-16 : 12:49:51
so what should be your result? all records in table1 as new records on table2/3?
Go to Top of Page
   

- Advertisement -