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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How can I relate those two tables - SQL

Author  Topic 

Indyyan
Starting Member

31 Posts

Posted - 2004-07-19 : 10:18:57
Hello, how can I relate those two tables?

I have one table dbo.Best. I have to fill this table with archive files from 1994-04. For each year I have two textfiles to import.
Fact is that the primary key returns after 3-4 years. Up to now there is no problem i just create my own key with:

UPDATE dbo.Best
SET UniqBest = CreatedDate +'-'+ Best_Nr


Here is the problem:
For every PK in the Table Best exist 5-10 records in the second table Besttranslogg. My question is, how can I realte this two tables, without failures???

The only possibility I can imagine is to import only the textfiles for the table Best and Besttranslogg from 1994 and create a relation between those two.

Is this the only way, because this sollution would mean a lot of work and problems??

nr
SQLTeam MVY

12543 Posts

Posted - 2004-07-19 : 12:51:27
Don't create the PK like that - better to have another field for the date and make the PK on the two columns.
Should the tables have a 1-1 join? Is the problem that you are just using the Best_Nr to join the tables? Can you use the date as well? If necessary make the date just the year.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -