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 2005 Forums
 Transact-SQL (2005)
 Comparing tables without primary keys

Author  Topic 

Guilth
Starting Member

6 Posts

Posted - 2008-09-23 : 14:38:19
Hello everyone,

I have a little problem here and I was wondering if one of you could have a solution for me.

I have to compare 2 tables to find all the differences between the two. Their schemas are the same.

The problem is, there is no primary keys in the tables and I can't add keys because of the way the tables are used by other softwares.

Am I doomed ? Is there a way to compare lines that aren't necessarily in the same order without keys ?

Thanks for your help!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-23 : 14:42:38
1. why it doesnt have a pk?
2. Even if it dont have pk, can you identify combination of columns whose values will identify a unique row of table?
Go to Top of Page

Guilth
Starting Member

6 Posts

Posted - 2008-09-23 : 15:06:04
1. I know it seems strange, but I'm not the designer of that DB. This table is a temporary table whose stocking raw information uploaded from an old informix DB before being treated to fill another table. It would seem that the table in Informix don't have any key, and that I can't add one in the temporary table without compromising the treatments done on it by some stocked procedures.

2. I could identify some columns combinations to make up for the lack of pk, but I have no garanties it'll work all the times because some entries are quite similar. And in fact, I need a way to compare a lot more than 2 tables so I would have to write a new SQL query each time.
Go to Top of Page
   

- Advertisement -